Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
lancet
/
kvcache
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
93df9f43
authored
Apr 24, 2020
by
lancet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
vault value is abstract now
parent
a0c4b68e
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
7 additions
and
7 deletions
+7
-7
vault/data.go
+2
-2
vault/public.go
+2
-2
vault/store.go
+3
-3
No files found.
vault/data.go
View file @
93df9f43
...
@@ -4,7 +4,7 @@ package vault
...
@@ -4,7 +4,7 @@ package vault
// запрос/ответ
// запрос/ответ
type
Message
struct
{
type
Message
struct
{
Key
string
Key
string
Value
string
Value
interface
{}
Action
string
// SET, GET, DEL, POP
Action
string
// SET, GET, DEL, POP
Error
bool
Error
bool
Reply
chan
Message
Reply
chan
Message
...
@@ -14,7 +14,7 @@ type Message struct {
...
@@ -14,7 +14,7 @@ type Message struct {
type
node
struct
{
type
node
struct
{
Kind
bool
// 0 - таймаут, 1 - данные
Kind
bool
// 0 - таймаут, 1 - данные
Key
string
// Ключ
Key
string
// Ключ
Value
string
// Хранимое значение
Value
interface
{}
// Хранимое значение
Prev
*
node
// Ближе к голове, извлекается раньше
Prev
*
node
// Ближе к голове, извлекается раньше
Next
*
node
// Ближе к хвосту, выйдёт позже
Next
*
node
// Ближе к хвосту, выйдёт позже
}
}
...
...
vault/public.go
View file @
93df9f43
...
@@ -7,7 +7,7 @@ import (
...
@@ -7,7 +7,7 @@ import (
)
)
// GetValue - получить значение ключа из хранилища
// GetValue - получить значение ключа из хранилища
func
(
store
*
Store
)
GetValue
(
key
string
)
(
string
,
error
)
{
func
(
store
*
Store
)
GetValue
(
key
string
)
(
interface
{}
,
error
)
{
if
store
.
isInit
==
false
{
if
store
.
isInit
==
false
{
store
.
init
()
store
.
init
()
}
}
...
@@ -22,7 +22,7 @@ func (store *Store) GetValue(key string) (string, error) {
...
@@ -22,7 +22,7 @@ func (store *Store) GetValue(key string) (string, error) {
}
}
// SetValue - установить/обновить значение ключа
// SetValue - установить/обновить значение ключа
func
(
store
*
Store
)
SetValue
(
key
,
value
string
)
error
{
func
(
store
*
Store
)
SetValue
(
key
string
,
value
interface
{}
)
error
{
if
store
.
isInit
==
false
{
if
store
.
isInit
==
false
{
store
.
init
()
store
.
init
()
}
}
...
...
vault/store.go
View file @
93df9f43
...
@@ -29,7 +29,7 @@ func (store *Store) init() {
...
@@ -29,7 +29,7 @@ func (store *Store) init() {
}
}
// addNode - добавляем новый узел в хвост очереди.
// addNode - добавляем новый узел в хвост очереди.
func
(
store
*
Store
)
addNode
(
key
,
value
string
,
kind
bool
)
error
{
func
(
store
*
Store
)
addNode
(
key
string
,
value
interface
{}
,
kind
bool
)
error
{
var
prev
*
node
var
prev
*
node
if
store
.
tail
!=
nil
{
if
store
.
tail
!=
nil
{
prev
=
store
.
tail
prev
=
store
.
tail
...
@@ -50,7 +50,7 @@ func (store *Store) addNode(key, value string, kind bool) error {
...
@@ -50,7 +50,7 @@ func (store *Store) addNode(key, value string, kind bool) error {
// setNode - собираемся добавить новый узел.
// setNode - собираемся добавить новый узел.
// Если ключа ещё нет - просто добавляем в хвост.
// Если ключа ещё нет - просто добавляем в хвост.
// Если ключ есть - переносим в хвост.
// Если ключ есть - переносим в хвост.
func
(
store
*
Store
)
setNode
(
key
,
value
string
)
error
{
func
(
store
*
Store
)
setNode
(
key
string
,
value
interface
{}
)
error
{
if
_
,
ok
:=
store
.
flat
[
key
];
ok
==
false
{
if
_
,
ok
:=
store
.
flat
[
key
];
ok
==
false
{
store
.
addNode
(
key
,
value
,
true
)
store
.
addNode
(
key
,
value
,
true
)
return
nil
return
nil
...
@@ -82,7 +82,7 @@ func (store *Store) popNode() error {
...
@@ -82,7 +82,7 @@ func (store *Store) popNode() error {
}
}
// getNode - получить значение ключа, или ошибку, если такого нет.
// getNode - получить значение ключа, или ошибку, если такого нет.
func
(
store
*
Store
)
getNode
(
key
string
)
(
string
,
error
)
{
func
(
store
*
Store
)
getNode
(
key
string
)
(
interface
{}
,
error
)
{
if
v
,
ok
:=
store
.
flat
[
key
];
ok
!=
false
{
if
v
,
ok
:=
store
.
flat
[
key
];
ok
!=
false
{
return
v
.
Value
,
nil
return
v
.
Value
,
nil
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment