Documentation ¶
Overview ¶
Package lru contains a LRU cache eviction implementation.
Index ¶
- type Element
- type TieredCacheStats
- type TieredLRUCache
- func (tc *TieredLRUCache) AddObject(oi *types.ObjectIndex) error
- func (tc *TieredLRUCache) ChangeConfig(bulkRemoveTimout, bulkRemoveCount, newsize uint64)
- func (tc *TieredLRUCache) ConsumedSize() types.BytesSize
- func (tc *TieredLRUCache) Lookup(oi *types.ObjectIndex) bool
- func (tc *TieredLRUCache) PromoteObject(oi *types.ObjectIndex)
- func (tc *TieredLRUCache) Remove(ois ...*types.ObjectIndex)
- func (tc *TieredLRUCache) ShouldKeep(oi *types.ObjectIndex) bool
- func (tc *TieredLRUCache) Stats() types.CacheStats
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Element ¶
type Element struct { // Pointer to the linked list element ListElem *list.Element // In which tier this LRU element is. Tiers are from 0 up to cacheTiers ListTier int }
Element is stored in the cache lookup hashmap
type TieredCacheStats ¶
type TieredCacheStats struct {
// contains filtered or unexported fields
}
TieredCacheStats is used by the LRUCache to implement the CacheStats interface.
func (*TieredCacheStats) CacheHitPrc ¶
func (lcs *TieredCacheStats) CacheHitPrc() string
CacheHitPrc implements part of CacheStats interface
func (*TieredCacheStats) Hits ¶
func (lcs *TieredCacheStats) Hits() uint64
Hits implements part of CacheStats interface
func (*TieredCacheStats) ID ¶
func (lcs *TieredCacheStats) ID() string
ID implements part of CacheStats interface
func (*TieredCacheStats) Objects ¶
func (lcs *TieredCacheStats) Objects() uint64
Objects implements part of CacheStats interface
func (*TieredCacheStats) Requests ¶
func (lcs *TieredCacheStats) Requests() uint64
Requests implements part of CacheStats interface
func (*TieredCacheStats) Size ¶
func (lcs *TieredCacheStats) Size() types.BytesSize
Size implements part of CacheStats interface
type TieredLRUCache ¶
type TieredLRUCache struct { types.SyncLogger // contains filtered or unexported fields }
TieredLRUCache implements segmented LRU Cache. It has cacheTiers segments.
func New ¶
func New(cz *config.CacheZone, removeFunc func(*types.ObjectIndex) error, logger types.Logger) *TieredLRUCache
New returns TieredLRUCache object ready for use.
func (*TieredLRUCache) AddObject ¶
func (tc *TieredLRUCache) AddObject(oi *types.ObjectIndex) error
AddObject implements part of types.CacheAlgorithm interface
func (*TieredLRUCache) ChangeConfig ¶
func (tc *TieredLRUCache) ChangeConfig(bulkRemoveTimout, bulkRemoveCount, newsize uint64)
ChangeConfig changes the TieredLRUCache config and start using it
func (*TieredLRUCache) ConsumedSize ¶
func (tc *TieredLRUCache) ConsumedSize() types.BytesSize
ConsumedSize implements part of types.CacheAlgorithm interface
func (*TieredLRUCache) Lookup ¶
func (tc *TieredLRUCache) Lookup(oi *types.ObjectIndex) bool
Lookup implements part of types.CacheAlgorithm interface
func (*TieredLRUCache) PromoteObject ¶
func (tc *TieredLRUCache) PromoteObject(oi *types.ObjectIndex)
PromoteObject implements part of types.CacheAlgorithm interface. It will reorder the linked lists so that this object index will be promoted in rank.
func (*TieredLRUCache) Remove ¶
func (tc *TieredLRUCache) Remove(ois ...*types.ObjectIndex)
Remove the objects given from the cache.
func (*TieredLRUCache) ShouldKeep ¶
func (tc *TieredLRUCache) ShouldKeep(oi *types.ObjectIndex) bool
ShouldKeep implements part of types.CacheAlgorithm interface
func (*TieredLRUCache) Stats ¶
func (tc *TieredLRUCache) Stats() types.CacheStats
Stats implements part of types.CacheAlgorithm interface