Documentation ¶
Index ¶
- type MemoryStore
- func (ms *MemoryStore) Count() uint64
- func (ms *MemoryStore) Delete(key []byte)
- func (ms *MemoryStore) ExpireKeys()
- func (ms *MemoryStore) Get(key []byte) (data []byte, found bool)
- func (ms *MemoryStore) Iterate(callback func(key, value []byte))
- func (ms *MemoryStore) Set(key []byte, data []byte) error
- func (ms *MemoryStore) StoreExpire(key []byte, data []byte, expiration time.Time) error
- type PogrebStore
- func (store *PogrebStore) Count() uint64
- func (store *PogrebStore) Delete(key []byte)
- func (store *PogrebStore) ExpireKeys()
- func (store *PogrebStore) Get(key []byte) (data []byte, found bool)
- func (store *PogrebStore) Iterate(callback func(key, value []byte))
- func (store *PogrebStore) Set(key []byte, data []byte) error
- func (store *PogrebStore) StoreExpire(key []byte, data []byte, expiration time.Time) error
- type Store
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MemoryStore ¶
type MemoryStore struct {
// contains filtered or unexported fields
}
MemoryStore is a simple in-memory key-value store for testing purposes.
func NewMemoryStore ¶
func NewMemoryStore() *MemoryStore
NewMemoryStore create a properly initialized memory store.
func (*MemoryStore) Count ¶
func (ms *MemoryStore) Count() uint64
Count returns the count of records stored.
func (*MemoryStore) Delete ¶
func (ms *MemoryStore) Delete(key []byte)
Delete deletes a key-value pair.
func (*MemoryStore) ExpireKeys ¶
func (ms *MemoryStore) ExpireKeys()
ExpireKeys is called to delete all keys that are marked for expiration.
func (*MemoryStore) Get ¶
func (ms *MemoryStore) Get(key []byte) (data []byte, found bool)
Get returns the value for the key if present.
func (*MemoryStore) Iterate ¶
func (ms *MemoryStore) Iterate(callback func(key, value []byte))
Iterate iterates over all records.
func (*MemoryStore) Set ¶
func (ms *MemoryStore) Set(key []byte, data []byte) error
Set stores the key-value pair.
func (*MemoryStore) StoreExpire ¶
StoreExpire stores the key-value pair and deletes it after the expiration time.
type PogrebStore ¶
type PogrebStore struct {
// contains filtered or unexported fields
}
PogrebStore is a key-value store using Pogreb. Expiration is currently not supported.
func NewPogrebStore ¶
func NewPogrebStore(filename string) (store *PogrebStore, err error)
NewPogrebStore create a properly initialized Pogreb store.
func (*PogrebStore) Count ¶
func (store *PogrebStore) Count() uint64
Count returns the count of records stored.
func (*PogrebStore) Delete ¶
func (store *PogrebStore) Delete(key []byte)
Delete deletes a key-value pair.
func (*PogrebStore) ExpireKeys ¶
func (store *PogrebStore) ExpireKeys()
func (*PogrebStore) Get ¶
func (store *PogrebStore) Get(key []byte) (data []byte, found bool)
Get returns the value for the key if present.
func (*PogrebStore) Iterate ¶
func (store *PogrebStore) Iterate(callback func(key, value []byte))
Iterate iterates over all records.
func (*PogrebStore) Set ¶
func (store *PogrebStore) Set(key []byte, data []byte) error
Store stores the key-value pair.
func (*PogrebStore) StoreExpire ¶
StoreExpire stores the key-value pair and deletes it after the expiration time.
type Store ¶
type Store interface { // 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 // 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) // ExpireKeys is called to delete all keys that are marked for expiration. ExpireKeys() // Count returns the total number of records stored. Count() uint64 // Iterate iterates over all records. Iterate(callback func(key, value []byte)) }
Store is the interface for implementing the storage mechanism for the DHT.