Documentation ¶
Index ¶
- func DecodeFromString(hexString string) ([]byte, error)
- func EncodeToString(hexBytes []byte) string
- func Is(err error, t StoreErrType) bool
- func NewTestLogger(t testing.TB) *logrus.Logger
- type EvictCallback
- type LRU
- func (c *LRU) Add(key, value interface{}) bool
- func (c *LRU) Contains(key interface{}) (ok bool)
- func (c *LRU) Get(key interface{}) (value interface{}, ok bool)
- func (c *LRU) GetOldest() (interface{}, interface{}, bool)
- func (c *LRU) Keys() []interface{}
- func (c *LRU) Len() int
- func (c *LRU) Peek(key interface{}) (value interface{}, ok bool)
- func (c *LRU) Purge()
- func (c *LRU) Remove(key interface{}) bool
- func (c *LRU) RemoveOldest() (interface{}, interface{}, bool)
- type RollingIndex
- func (r *RollingIndex) Get(skipIndex int) ([]interface{}, error)
- func (r *RollingIndex) GetItem(index int) (interface{}, error)
- func (r *RollingIndex) GetLastWindow() (lastWindow []interface{}, lastIndex int)
- func (r *RollingIndex) Roll()
- func (r *RollingIndex) Set(item interface{}, index int) error
- type RollingIndexMap
- func (rim *RollingIndexMap) AddKey(key uint32) error
- func (rim *RollingIndexMap) Get(key uint32, skipIndex int) ([]interface{}, error)
- func (rim *RollingIndexMap) GetItem(key uint32, index int) (interface{}, error)
- func (rim *RollingIndexMap) GetLast(key uint32) (interface{}, error)
- func (rim *RollingIndexMap) Known() map[uint32]int
- func (rim *RollingIndexMap) Set(key uint32, item interface{}, index int) error
- type StoreErr
- type StoreErrType
- type Trilean
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DecodeFromString ¶
DecodeFromString converts a hex string with 0X prefix to a byte slice
func EncodeToString ¶
EncodeToString returns the UPPERCASE string representation of hexBytes with the 0X prefix
Types ¶
type EvictCallback ¶
type EvictCallback func(key interface{}, value interface{})
EvictCallback is used to get a callback when a cache entry is evicted
type LRU ¶
type LRU struct {
// contains filtered or unexported fields
}
LRU implements a non-thread safe fixed size LRU cache
func NewLRU ¶
func NewLRU(size int, onEvict EvictCallback) *LRU
NewLRU constructs an LRU of the given size
func (*LRU) Contains ¶
Check if a key is in the cache, without updating the recent-ness or deleting it for being stale.
func (*LRU) Keys ¶
func (c *LRU) Keys() []interface{}
Keys returns a slice of the keys in the cache, from oldest to newest.
func (*LRU) Peek ¶
Returns the key value (or undefined if not found) without updating the "recently used"-ness of the key.
func (*LRU) Remove ¶
Remove removes the provided key from the cache, returning if the key was contained.
func (*LRU) RemoveOldest ¶
RemoveOldest removes the oldest item from the cache.
type RollingIndex ¶
type RollingIndex struct {
// contains filtered or unexported fields
}
RollingIndex ...
func NewRollingIndex ¶
func NewRollingIndex(name string, size int) *RollingIndex
NewRollingIndex ...
func (*RollingIndex) GetItem ¶
func (r *RollingIndex) GetItem(index int) (interface{}, error)
GetItem ...
func (*RollingIndex) GetLastWindow ¶
func (r *RollingIndex) GetLastWindow() (lastWindow []interface{}, lastIndex int)
GetLastWindow ...
type RollingIndexMap ¶
type RollingIndexMap struct {
// contains filtered or unexported fields
}
RollingIndexMap ...
func NewRollingIndexMap ¶
func NewRollingIndexMap(name string, size int) *RollingIndexMap
NewRollingIndexMap ...
func (*RollingIndexMap) Get ¶
func (rim *RollingIndexMap) Get(key uint32, skipIndex int) ([]interface{}, error)
Get return key items with index > skip
func (*RollingIndexMap) GetItem ¶
func (rim *RollingIndexMap) GetItem(key uint32, index int) (interface{}, error)
GetItem ...
func (*RollingIndexMap) GetLast ¶
func (rim *RollingIndexMap) GetLast(key uint32) (interface{}, error)
GetLast ...
func (*RollingIndexMap) Known ¶
func (rim *RollingIndexMap) Known() map[uint32]int
Known returns [key] => lastKnownIndex
type StoreErr ¶
type StoreErr struct {
// contains filtered or unexported fields
}
StoreErr ...
func NewStoreErr ¶
func NewStoreErr(dataType string, errType StoreErrType, key string) StoreErr
NewStoreErr ...
type StoreErrType ¶
type StoreErrType uint32
StoreErrType ...
const ( // KeyNotFound ... KeyNotFound StoreErrType = iota // TooLate ... TooLate // PassedIndex ... PassedIndex // SkippedIndex ... SkippedIndex // NoRoot ... NoRoot // UnknownParticipant ... UnknownParticipant // Empty ... Empty // KeyAlreadyExists ... KeyAlreadyExists // NoPeerSet ... NoPeerSet )