Documentation ¶
Overview ¶
Package s4lru implements the 4-segmented LRU caching algorithm
From http://www.cs.cornell.edu/~qhuang/papers/sosp_fbanalysis.pdf
Four queues are maintained at levels 0 to 3. On a cache miss, the item is inserted at the head of queue 0. On a cache hit, the item is moved to the head of the next higher queue (items in queue 3 move to the head of queue 3). Each queue is allocated 1/4 of the total cache size and items are evicted from the tail of a queue to the head of the next lower queue to maintain the size invariants. Items evicted from queue 0 are evicted from the cache
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
Cache is an LRU cache. It is not safe for concurrent access.
func New ¶
New returns a new S4LRU cache that with the given capacity. Each of the lists will have 1/4 of the capacity. New will panic if the capacity is not evenly divisible by 4.
Click to show internal directories.
Click to hide internal directories.