Key/value database rename functions.

This commit is contained in:
Kleissner
2021-08-11 22:16:39 +02:00
parent d87e43cd32
commit 3da1acde60
4 changed files with 18 additions and 18 deletions

View File

@@ -39,8 +39,8 @@ func (ms *MemoryStore) ExpireKeys() {
}
}
// Store stores the key/value pair.
func (ms *MemoryStore) Store(key []byte, data []byte) error {
// Set stores the key/value pair.
func (ms *MemoryStore) Set(key []byte, data []byte) error {
ms.mutex.Lock()
ms.data[string(key)] = data
ms.mutex.Unlock()
@@ -56,8 +56,8 @@ func (ms *MemoryStore) StoreExpire(key []byte, data []byte, expiration time.Time
return nil
}
// Retrieve returns the value for the key if present.
func (ms *MemoryStore) Retrieve(key []byte) (data []byte, found bool) {
// Get returns the value for the key if present.
func (ms *MemoryStore) Get(key []byte) (data []byte, found bool) {
ms.mutex.Lock()
data, found = ms.data[string(key)]
ms.mutex.Unlock()

View File

@@ -14,15 +14,15 @@ import (
// Store is the interface for implementing the storage mechanism for the DHT.
type Store interface {
// Store stores the key/value pair.
Store(key []byte, data []byte) error
// Set stores the key/value pair.
Set(key []byte, data []byte) error
// StoreExpire stores the key/value pair and deletes it after the expiration time.
// If key/value already exists, it will be overwritten and the new expiration time applies.
StoreExpire(key []byte, data []byte, expiration time.Time) error
// Retrieve returns the value for the key if present.
Retrieve(key []byte) (data []byte, found bool)
// Get returns the value for the key if present.
Get(key []byte) (data []byte, found bool)
// Delete deletes a key/value pair.
Delete(key []byte)