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
da84fa58
authored
Aug 25, 2019
by
lancet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
more WIP
parent
630da929
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
5 additions
and
4 deletions
+5
-4
vault/control.go
+1
-0
vault/data.go
+1
-1
vault/store.go
+3
-3
No files found.
vault/control.go
0 → 100644
View file @
da84fa58
package
vault
vault/data.go
View file @
da84fa58
...
...
@@ -23,7 +23,7 @@ type node struct {
// Store - корневая структура для хранения данных
type
store
struct
{
exchange
chan
Message
// Небуферизованный канал для синхронизации доступа
ttl
time
.
Time
// Время жизни узла
ttl
time
.
Duration
// Время жизни узла
head
*
node
tail
*
node
flat
map
[
string
]
*
node
// Карта для быстрого доступа к значениям
...
...
vault/store.go
View file @
da84fa58
...
...
@@ -3,7 +3,7 @@ package vault
import
"errors"
// addNode - добавляем новый узел в хвост очереди.
func
(
store
*
store
)
addNode
(
key
,
value
string
)
{
func
(
store
*
store
)
addNode
(
key
,
value
string
,
kind
bool
)
{
prev
:=
store
.
tail
store
.
tail
=
&
node
{
Key
:
key
,
Value
:
value
,
Prev
:
prev
,
Kind
:
true
}
prev
.
Next
=
store
.
tail
...
...
@@ -15,7 +15,7 @@ func (store *store) addNode(key, value string) {
// Если ключ есть - переносим в хвост.
func
(
store
*
store
)
setNode
(
key
,
value
string
)
error
{
if
_
,
ok
:=
store
.
flat
[
key
];
ok
==
false
{
store
.
addNode
(
key
,
value
)
store
.
addNode
(
key
,
value
,
true
)
return
nil
}
// Вместо того, чтобы удалить и пересоздать, просто правим ссылки.
...
...
@@ -37,7 +37,7 @@ func (store *store) setNode(key, value string) error {
store
.
tail
=
next
}
store
.
head
=
node
node
.
Prev
=
head
node
.
Next
=
head
return
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