Documentation
¶
Index ¶
- func Hash32(data []byte) int
- 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) Get(key int, skipIndex int) ([]interface{}, error)
- func (rim *RollingIndexMap) GetItem(key int, index int) (interface{}, error)
- func (rim *RollingIndexMap) GetLast(key int) (interface{}, error)
- func (rim *RollingIndexMap) Known() map[int]int
- func (rim *RollingIndexMap) Reset() error
- func (rim *RollingIndexMap) Set(key int, item interface{}, index int) error
- type StoreErr
- type StoreErrType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Is ¶
func Is(err error, t StoreErrType) bool
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
}
func NewRollingIndex ¶
func NewRollingIndex(name string, size int) *RollingIndex
func (*RollingIndex) Get ¶
func (r *RollingIndex) Get(skipIndex int) ([]interface{}, error)
func (*RollingIndex) GetItem ¶
func (r *RollingIndex) GetItem(index int) (interface{}, error)
func (*RollingIndex) GetLastWindow ¶
func (r *RollingIndex) GetLastWindow() (lastWindow []interface{}, lastIndex int)
func (*RollingIndex) Roll ¶
func (r *RollingIndex) Roll()
func (*RollingIndex) Set ¶
func (r *RollingIndex) Set(item interface{}, index int) error
type RollingIndexMap ¶
type RollingIndexMap struct {
// contains filtered or unexported fields
}
func NewRollingIndexMap ¶
func NewRollingIndexMap(name string, size int, keys []int) *RollingIndexMap
func (*RollingIndexMap) Get ¶
func (rim *RollingIndexMap) Get(key int, skipIndex int) ([]interface{}, error)
return key items with index > skip
func (*RollingIndexMap) GetItem ¶
func (rim *RollingIndexMap) GetItem(key int, index int) (interface{}, error)
func (*RollingIndexMap) GetLast ¶
func (rim *RollingIndexMap) GetLast(key int) (interface{}, error)
func (*RollingIndexMap) Known ¶
func (rim *RollingIndexMap) Known() map[int]int
returns [key] => lastKnownIndex
func (*RollingIndexMap) Reset ¶
func (rim *RollingIndexMap) Reset() error
type StoreErr ¶
type StoreErr struct {
// contains filtered or unexported fields
}
func NewStoreErr ¶
func NewStoreErr(dataType string, errType StoreErrType, key string) StoreErr
type StoreErrType ¶
type StoreErrType uint32
const ( KeyNotFound StoreErrType = iota TooLate PassedIndex SkippedIndex NoRoot UnknownParticipant Empty )
Click to show internal directories.
Click to hide internal directories.