Documentation ¶
Overview ¶
Package cache is implements the caching algorithm. It defines the CacheManager interface. Every CacheZone has its own cache manager. This makes it possible for different caching algorithms to be used in the same time.
Index ¶
- type CacheManager
- type CacheStats
- type LRUCache
- func (l *LRUCache) AddObjectIndex(oi ObjectIndex) error
- func (l *LRUCache) ConsumedSize() config.BytesSize
- func (l *LRUCache) Has(oi ObjectIndex) bool
- func (l *LRUCache) Init()
- func (l *LRUCache) ObjectIndexStored(oi ObjectIndex) bool
- func (l *LRUCache) ReplaceRemoveChannel(ch chan<- ObjectIndex)
- func (l *LRUCache) Stats() *CacheStats
- func (l *LRUCache) UsedObjectIndex(oi ObjectIndex)
- type LRUElement
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CacheManager ¶
type CacheManager interface { // Init is called only once after creating the CacheManager object Init() // Has returns wheather this object is in the cache or not Has(types.ObjectIndex) bool // ObjectIndexStored is called to signal that this ObjectIndex has been stored ObjectIndexStored(types.ObjectIndex) bool // AddObjectIndex adds this ObjectIndex to the cache AddObjectIndex(types.ObjectIndex) error // UsedObjectIndex is called every time this part of a file has been used // to satisfy a client request UsedObjectIndex(types.ObjectIndex) // ConsumedSize returns the full size of all files currently in the cache ConsumedSize() config.BytesSize // ReplaceRemoveChannel makes this cache communicate its desire to remove objects // on this channel ReplaceRemoveChannel(chan<- types.ObjectIndex) // Stats returns statistics for this cache manager Stats() *CacheStats }
CacheManager interface defines how a cache should behave
func NewCacheManager ¶
func NewCacheManager(ct string, cz *config.CacheZoneSection) (CacheManager, error)
NewCacheManager creates and returns a particular type of cache manager.
type CacheStats ¶
type CacheStats struct { ID string Hits uint64 Requests uint64 Size config.BytesSize Objects uint64 }
func (*CacheStats) CachHitPrc ¶
func (c *CacheStats) CachHitPrc() string
type LRUCache ¶
type LRUCache struct { CacheZone *config.CacheZoneSection // contains filtered or unexported fields }
Implements segmented LRU Cache. It has cacheTiers segments.
func (*LRUCache) AddObjectIndex ¶
Implements part of CacheManager interface
func (*LRUCache) ConsumedSize ¶
Implements part of CacheManager interface
func (*LRUCache) ObjectIndexStored ¶
Implements part of CacheManager interface
func (*LRUCache) ReplaceRemoveChannel ¶
func (l *LRUCache) ReplaceRemoveChannel(ch chan<- ObjectIndex)
func (*LRUCache) Stats ¶
func (l *LRUCache) Stats() *CacheStats
Implements part of CacheManager interface
func (*LRUCache) UsedObjectIndex ¶
func (l *LRUCache) UsedObjectIndex(oi ObjectIndex)
Implements part of CacheManager interface. It will reorder the linke lists so that this object index will be get promoted in rank.