Commit 93df9f43 by lancet

vault value is abstract now

parent a0c4b68e
......@@ -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
......@@ -14,7 +14,7 @@ type Message struct {
type node struct {
Kind bool // 0 - таймаут, 1 - данные
Key string // Ключ
Value string // Хранимое значение
Value interface{} // Хранимое значение
Prev *node // Ближе к голове, извлекается раньше
Next *node // Ближе к хвосту, выйдёт позже
}
......
......@@ -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()
}
......
......@@ -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
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment