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
4 years ago
by
lancet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
vault value is abstract now
parent
a0c4b68e
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
11 deletions
+11
-11
vault/data.go
+6
-6
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
// запрос/ответ
type
Message
struct
{
Key
string
Value
string
Value
interface
{}
Action
string
// SET, GET, DEL, POP
Error
bool
Reply
chan
Message
...
...
@@ -12,11 +12,11 @@ type Message struct {
// node - узел данных для очереди устаревания
type
node
struct
{
Kind
bool
// 0 - таймаут, 1 - данные
Key
string
// Ключ
Value
string
// Хранимое значение
Prev
*
node
// Ближе к голове, извлекается раньше
Next
*
node
// Ближе к хвосту, выйдёт позже
Kind
bool
// 0 - таймаут, 1 - данные
Key
string
// Ключ
Value
interface
{}
// Хранимое значение
Prev
*
node
// Ближе к голове, извлекается раньше
Next
*
node
// Ближе к хвосту, выйдёт позже
}
// Store - корневая структура для хранения данных
...
...
This diff is collapsed.
Click to expand it.
vault/public.go
View file @
93df9f43
...
...
@@ -7,7 +7,7 @@ import (
)
// GetValue - получить значение ключа из хранилища
func
(
store
*
Store
)
GetValue
(
key
string
)
(
string
,
error
)
{
func
(
store
*
Store
)
GetValue
(
key
string
)
(
interface
{}
,
error
)
{
if
store
.
isInit
==
false
{
store
.
init
()
}
...
...
@@ -22,7 +22,7 @@ func (store *Store) GetValue(key string) (string, error) {
}
// SetValue - установить/обновить значение ключа
func
(
store
*
Store
)
SetValue
(
key
,
value
string
)
error
{
func
(
store
*
Store
)
SetValue
(
key
string
,
value
interface
{}
)
error
{
if
store
.
isInit
==
false
{
store
.
init
()
}
...
...
This diff is collapsed.
Click to expand it.
vault/store.go
View file @
93df9f43
...
...
@@ -29,7 +29,7 @@ func (store *Store) init() {
}
// 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
if
store
.
tail
!=
nil
{
prev
=
store
.
tail
...
...
@@ -50,7 +50,7 @@ func (store *Store) addNode(key, value string, kind bool) error {
// 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
{
store
.
addNode
(
key
,
value
,
true
)
return
nil
...
...
@@ -82,7 +82,7 @@ func (store *Store) popNode() error {
}
// 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
{
return
v
.
Value
,
nil
}
...
...
This diff is collapsed.
Click to expand it.
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