Documentation ¶
Index ¶
- func NewBloomFilter(conf BloomConfig) (storage.BloomFilter, error)
- func NewCache(config CacheConfig) (storage.Cacher, error)
- func NewDB(argDB ArgDB) (storage.Persister, error)
- func NewNilStorer() *nilStorer
- type ArgDB
- type BloomConfig
- type CacheConfig
- type CacheType
- type DBConfig
- type DBType
- type HasherType
- type Unit
- func (u *Unit) ClearCache()
- func (u *Unit) Close() error
- func (u *Unit) DestroyUnit() error
- func (u *Unit) Get(key []byte) ([]byte, error)
- func (u *Unit) GetBulkFromEpoch(keys [][]byte, _ uint32) (map[string][]byte, error)
- func (u *Unit) GetFromEpoch(key []byte, _ uint32) ([]byte, error)
- func (u *Unit) Has(key []byte) error
- func (u *Unit) HasInEpoch(key []byte, _ uint32) error
- func (u *Unit) IsInterfaceNil() bool
- func (u *Unit) Put(key, data []byte) error
- func (u *Unit) PutInEpoch(key, data []byte, _ uint32) error
- func (u *Unit) RangeKeys(handler func(key []byte, value []byte) bool)
- func (u *Unit) Remove(key []byte) error
- func (u *Unit) SearchFirst(key []byte) ([]byte, error)
- type UnitConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewBloomFilter ¶
func NewBloomFilter(conf BloomConfig) (storage.BloomFilter, error)
NewBloomFilter creates a new bloom filter from bloom filter config
func NewCache ¶
func NewCache(config CacheConfig) (storage.Cacher, error)
NewCache creates a new cache from a cache config
Types ¶
type ArgDB ¶
type ArgDB struct { DBType DBType Path string BatchDelaySeconds int MaxBatchSize int MaxOpenFiles int }
ArgDB is a structure that is used to create a new storage.Persister implementation
type BloomConfig ¶
type BloomConfig struct { Size uint HashFunc []HasherType }
BloomConfig holds the configurable elements of a bloom filter
type CacheConfig ¶
type CacheConfig struct { Name string Type CacheType SizeInBytes uint64 SizeInBytesPerSender uint32 Capacity uint32 SizePerSender uint32 Shards uint32 }
CacheConfig holds the configurable elements of a cache
func (*CacheConfig) String ¶
func (config *CacheConfig) String() string
String returns a readable representation of the object
type DBConfig ¶
type DBConfig struct { FilePath string Type DBType BatchDelaySeconds int MaxBatchSize int MaxOpenFiles int }
DBConfig holds the configurable elements of a database
type HasherType ¶
type HasherType string
HasherType represents the type of the supported hash functions
const ( // Keccak is the string representation of the keccak hashing function Keccak HasherType = "Keccak" // Blake2b is the string representation of the blake2b hashing function Blake2b HasherType = "Blake2b" // Fnv is the string representation of the fnv hashing function Fnv HasherType = "Fnv" )
type Unit ¶
type Unit struct {
// contains filtered or unexported fields
}
Unit represents a storer's data bank holding the cache, persistence unit and bloom filter
func NewStorageUnit ¶
NewStorageUnit is the constructor for the storage unit, creating a new storage unit from the given cacher and persister.
func NewStorageUnitFromConf ¶
func NewStorageUnitFromConf(cacheConf CacheConfig, dbConf DBConfig, bloomFilterConf BloomConfig) (*Unit, error)
NewStorageUnitFromConf creates a new storage unit from a storage unit config
func NewStorageUnitWithBloomFilter ¶
func NewStorageUnitWithBloomFilter(c storage.Cacher, p storage.Persister, b storage.BloomFilter) (*Unit, error)
NewStorageUnitWithBloomFilter is the constructor for the storage unit, creating a new storage unit from the given cacher, persister and bloom filter.
func (*Unit) DestroyUnit ¶
DestroyUnit cleans up the bloom filter, the cache, and the db
func (*Unit) Get ¶
Get searches the key in the cache. In case it is not found, it searches for the key in bloom filter first and if found it further searches it in the associated database. In case it is found in the database, the cache is updated with the value as well.
func (*Unit) GetBulkFromEpoch ¶
GetBulkFromEpoch will call the Get method for all keys as this storer doesn't handle epochs
func (*Unit) GetFromEpoch ¶
GetFromEpoch will call the Get method as this storer doesn't handle epochs
func (*Unit) Has ¶
Has checks if the key is in the Unit. It first checks the cache. If it is not found, it checks the bloom filter and if present it checks the db
func (*Unit) HasInEpoch ¶
HasInEpoch will call the Has method as this storer doesn't handle epochs
func (*Unit) IsInterfaceNil ¶
IsInterfaceNil returns true if there is no value under the interface
func (*Unit) PutInEpoch ¶
PutInEpoch will call the Put method as this storer doesn't handle epochs
func (*Unit) RangeKeys ¶
RangeKeys can iterate over the persisted (key, value) pairs calling the provided handler
type UnitConfig ¶
type UnitConfig struct { CacheConf CacheConfig DBConf DBConfig BloomConf BloomConfig }
UnitConfig holds the configurable elements of the storage unit