Documentation ¶
Index ¶
- func HashSlice(key []byte) uint32
- type Cache
- type ChargeOperator
- type DeleteCallback
- type HandleTable
- func (this *HandleTable) ApplyToAllCacheEntries(travel_fun TravelEntryOperator)
- func (this *HandleTable) Insert(e *LRUHandle) *LRUHandle
- func (this *HandleTable) Lookup(key []byte, hash uint32) *LRUHandle
- func (this *HandleTable) Remove(key []byte, hash uint32) *LRUHandle
- func (this *HandleTable) Resize()
- type LRUCache
- func (this *LRUCache) ApplyToAllCacheEntries(travel_fun TravelEntryOperator)
- func (this *LRUCache) Delete(key string)
- func (this *LRUCache) Get(key string) (string, bool)
- func (this *LRUCache) Insert(key []byte, entry interface{}, charge uint64, deleter DeleteCallback)
- func (this *LRUCache) Lookup(key []byte) interface{}
- func (this *LRUCache) Merge(key []byte, entry interface{}, charge uint64, merge_opt MergeOperator, ...) interface{}
- func (this *LRUCache) NewId() uint64
- func (this *LRUCache) Prune()
- func (this *LRUCache) Put(key, value string)
- func (this *LRUCache) Remove(key []byte) interface{}
- func (this *LRUCache) SetCapacity(capacity uint64)
- func (this *LRUCache) TotalCharge() uint64
- type LRUCacheShard
- func (this *LRUCacheShard) ApplyToAllCacheEntries(travel_fun TravelEntryOperator)
- func (this *LRUCacheShard) EvictLRU()
- func (this *LRUCacheShard) Insert(key []byte, hash uint32, entry interface{}, charge uint64, ...) error
- func (this *LRUCacheShard) Lookup(key []byte, hash uint32) interface{}
- func (this *LRUCacheShard) Merge(key []byte, hash uint32, entry interface{}, charge uint64, merge MergeOperator, ...) interface{}
- func (this *LRUCacheShard) Prune()
- func (this *LRUCacheShard) Remove(key []byte, hash uint32) interface{}
- func (this *LRUCacheShard) SetCapacity(capacity uint64)
- func (this *LRUCacheShard) TotalCharge() uint64
- type LRUHandle
- type MergeOperator
- type TravelEntryOperator
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Cache ¶
type Cache interface { Put(key string, value string) Get(key string) (string, bool) Delete(key string) NewId() uint64 Prune() TotalCharge() uint64 Insert(key []byte, entry interface{}, charge uint64, deleter DeleteCallback) Lookup(key []byte) interface{} Remove(key []byte) interface{} Merge(key []byte, entry interface{}, charge uint64, merge_opt MergeOperator, charge_opt ChargeOperator) (old_entry interface{}) ApplyToAllCacheEntries(TravelEntryOperator) }
type ChargeOperator ¶
type DeleteCallback ¶
type DeleteCallback func(key []byte, entry interface{})
type HandleTable ¶
type HandleTable struct {
// contains filtered or unexported fields
}
func NewLRUHandleTable ¶
func NewLRUHandleTable() *HandleTable
func (*HandleTable) ApplyToAllCacheEntries ¶
func (this *HandleTable) ApplyToAllCacheEntries(travel_fun TravelEntryOperator)
func (*HandleTable) Insert ¶
func (this *HandleTable) Insert(e *LRUHandle) *LRUHandle
*
when not find return nil; else replace handl and return old handle
func (*HandleTable) Resize ¶
func (this *HandleTable) Resize()
type LRUCache ¶
type LRUCache struct {
// contains filtered or unexported fields
}
impl of interface Cache
func NewLRUCache ¶
func (*LRUCache) ApplyToAllCacheEntries ¶
func (this *LRUCache) ApplyToAllCacheEntries(travel_fun TravelEntryOperator)
func (*LRUCache) Insert ¶
func (this *LRUCache) Insert(key []byte, entry interface{}, charge uint64, deleter DeleteCallback)
func (*LRUCache) Merge ¶
func (this *LRUCache) Merge(key []byte, entry interface{}, charge uint64, merge_opt MergeOperator, charge_opt ChargeOperator) interface{}
func (*LRUCache) SetCapacity ¶
func (*LRUCache) TotalCharge ¶
type LRUCacheShard ¶
type LRUCacheShard struct {
// contains filtered or unexported fields
}
func NewLRUCacheShard ¶
func NewLRUCacheShard(capacity uint64) *LRUCacheShard
func (*LRUCacheShard) ApplyToAllCacheEntries ¶
func (this *LRUCacheShard) ApplyToAllCacheEntries(travel_fun TravelEntryOperator)
func (*LRUCacheShard) EvictLRU ¶
func (this *LRUCacheShard) EvictLRU()
func (*LRUCacheShard) Insert ¶
func (this *LRUCacheShard) Insert(key []byte, hash uint32, entry interface{}, charge uint64, deleter DeleteCallback) error
* create lruhandle and Insert to cache,
func (*LRUCacheShard) Lookup ¶
func (this *LRUCacheShard) Lookup(key []byte, hash uint32) interface{}
* find key's lruhandle, return nil if not find;
func (*LRUCacheShard) Merge ¶
func (this *LRUCacheShard) Merge(key []byte, hash uint32, entry interface{}, charge uint64, merge MergeOperator, charge_opt ChargeOperator) interface{}
func (*LRUCacheShard) Prune ¶
func (this *LRUCacheShard) Prune()
func (*LRUCacheShard) Remove ¶
func (this *LRUCacheShard) Remove(key []byte, hash uint32) interface{}
func (*LRUCacheShard) SetCapacity ¶
func (this *LRUCacheShard) SetCapacity(capacity uint64)
func (*LRUCacheShard) TotalCharge ¶
func (this *LRUCacheShard) TotalCharge() uint64
type MergeOperator ¶
type MergeOperator func(old_entry, new_entry interface{}) interface{}
var Int64MergeOperator MergeOperator = func(old_entry, new_entry interface{}) interface{} { if old_entry == nil { return new_entry } old, ok_old := old_entry.(int64) new, ok_new := new_entry.(int64) if !ok_old || !ok_new { panic("error of merge type, old:" + reflect.TypeOf(old_entry).Name() + " new:" + reflect.TypeOf(new_entry).Name()) } res := old + new return res }
var IntMergeOperator MergeOperator = func(old_entry, new_entry interface{}) interface{} { if old_entry == nil { return new_entry } old, ok_old := old_entry.(int) new, ok_new := new_entry.(int) if !ok_old || !ok_new { panic("error of merge type, old:" + reflect.TypeOf(old_entry).Name() + " new:" + reflect.TypeOf(new_entry).Name()) } res := old + new return res }
type TravelEntryOperator ¶
type TravelEntryOperator func(key []byte, entry interface{})
Click to show internal directories.
Click to hide internal directories.