Documentation ¶
Overview ¶
Package store provides interfaces and default in-memory implementation of storage for DHT metadata.
Usage:
s := newMemoryStore() data := []byte("some data") key := NewKey(data) replicationTime := time.Now().Add(time.Second * 1337) expirationTime := time.Now().Add(time.Second * 42) s.Store(key, data, replicationTime, expirationTime, true) s.Retrieve(key) s.Delete(key)
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Factory ¶
type Factory interface {
Create() Store
}
Factory allows to create new storage.
func NewMemoryStoreFactory ¶
func NewMemoryStoreFactory() Factory
NewMemoryStoreFactory creates new factory of memory storage.
type Store ¶
type Store interface { // Store should store a key/value pair for the local host with the // given replication and expiration times. Store(key Key, data []byte, replication time.Time, expiration time.Time, publisher bool) error // Retrieve should return the local key/value if it exists. Retrieve(key Key) (data []byte, found bool) // Delete should delete a key/value pair from the Store. Delete(key Key) // GetKeysReadyToReplicate should return the keys of all data to be // replicated across the network. Typically all data should be // replicated every tReplicate seconds. GetKeysReadyToReplicate() []Key // ExpireKeys should expire all key/values due for expiration. ExpireKeys() }
Store is the interface for implementing the storage mechanism for the DHT.
Click to show internal directories.
Click to hide internal directories.