Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
Create free account
hub
/
github.com/crowdriff/lru
/ functions
Functions
89 in github.com/crowdriff/lru
⨍
Functions
89
◇
Types & classes
14
↓ 54 callers
Method
Len
Len returns the total number of items in the LRU.
algorithm.go:16
↓ 41 callers
Function
closeBoltDB
(l *LRU)
lru_suite_test.go:32
↓ 34 callers
Function
newDefaultLRU
()
lru_suite_test.go:25
↓ 25 callers
Method
PutAndEvict
PutAndEvict inserts the provided key and size into the LRU and returns a slice of keys that have been evicted as well as the total size in bytes that
algorithm.go:21
↓ 23 callers
Method
Get
([]byte)
store.go:9
↓ 15 callers
Function
NewTwoQ
NewTwoQ returns a new TwoQ instance given the provided capacity, eviction ratio, warm/hot ratio, and cold ratio. evictRatio represents the percentage
twoq.go:63
↓ 12 callers
Method
getFromBolt
getFromBolt returns the value corresponding to the provided key from the bolt database, or nil if the key doesn't exist.
boltcache.go:49
↓ 12 callers
Method
pushToFront
pushToFront inserts the provided item into the front of the list.
twoq.go:263
↓ 11 callers
Method
Close
open the store
store.go:11
↓ 10 callers
Function
DefaultBasicLRU
DefaultBasicLRU returns a new BasicLRU instance with the provided capacity and an eviction ratio of 0.1%.
basiclru.go:17
↓ 10 callers
Function
DefaultTwoQ
DefaultTwoQ returns a new TwoQ LRU with the provided capacity.
twoq.go:49
↓ 10 callers
Function
NewLRU
NewLRU returns a new LRU object with the provided database path, bucket name, LRU algorithm, and remote store. Before using the returned LRU, its Open
lru.go:60
↓ 9 callers
Method
PutOnStartup
PutOnStartup adds the provided key and size to LRU and returns true if the key was successfully added.
algorithm.go:25
↓ 8 callers
Method
Size
Size returns the total size in bytes of all items in the LRU.
algorithm.go:28
↓ 8 callers
Method
put
put adds the provided key and value to the local cache and LRU. If the cache now exceeds its capacity, the least recently used item(s) will be evicted
lru.go:273
↓ 8 callers
Method
putIntoBolt
putIntoBolt writes the provided key and value into the bolt database and returns any error encountered.
boltcache.go:89
↓ 7 callers
Method
getFromStore
getFromStore attempts to retrieve the value with the provided key from the remote store. If another goroutine has already requested the same value, th
lru.go:205
↓ 6 callers
Method
Open
retrieve the value with the provided key
store.go:10
↓ 6 callers
Function
newBufferFromData
newBufferFromData returns a new Buffer from the provided byte slice.
bufpool.go:44
↓ 6 callers
Function
newStore
(get func([]byte) ([]byte, error))
lru_suite_test.go:46
↓ 5 callers
Method
Empty
Empty completely empties the LRU.
algorithm.go:9
↓ 5 callers
Method
GetBuffer
GetBuffer attempts to retrieve the value for the provided key, returning a Buffer. An error is returned if either no value exists or an error occurs w
lru.go:148
↓ 5 callers
Method
hit
hit registers a 'hit' for the provided key in the LRU and returns the size of the value in bytes if it exists. If no key was found, hit registers a 'm
lru.go:178
↓ 5 callers
Method
removeElem
removeElem removes the provided list element from the linked list and returns the associated item.
twoq.go:271
↓ 4 callers
Method
Cap
Cap returns the total capacity of the LRU in bytes.
algorithm.go:6
↓ 4 callers
Function
NewBasicLRU
NewBasicLRU returns a new BasicLRU with the provided capacity, and eviction ratio. evictRatio represents the percentage of items (based on size) that
basiclru.go:26
↓ 4 callers
Method
emptyBolt
emptyBolt completely empties the bolt database and returns any error encountered.
boltcache.go:98
↓ 4 callers
Method
evict
evict evicts items from the list until the twoQ LRU's size is less than or equal to its capacity. It returns a slice of keys that have been evicted an
twoq.go:280
↓ 4 callers
Method
getBufFromBolt
getBufFromBolt returns a buffer corresponding to the provided key from the bolt database, or nil if the key doesn't exist.
boltcache.go:69
↓ 4 callers
Function
isFront
(status uint8, tq *TwoQ, key string)
twoq_test.go:290
↓ 4 callers
Method
openBoltDB
openBoltDB opens the boltDB database and assigns it to the LRU as "db".
boltcache.go:10
↓ 4 callers
Method
prune
prune prunes any excess items off of the back of the warm LRU, or if under the warm/hot ratio, the hot LRU, and returns a slice of keys that have been
twoq.go:211
↓ 3 callers
Method
WriteTo
WriteTo writes the Buffer's contents to the provided io.Writer and returns the number of bytes written and any error encountered.
bufpool.go:72
↓ 3 callers
Method
empty
empty empties the list's underlying linked list and size.
twoq.go:257
↓ 3 callers
Function
newBufferFromBuf
newBufferFromBuf returns a new Buffer from the provided bytes.Buffer.
bufpool.go:39
↓ 3 callers
Function
newList
newList returns a new twoQList with the provided status, capacity, and twoQ LRU.
twoq.go:246
↓ 3 callers
Method
pruneCold
pruneCold prunes any excess items off of the back of the cold LRU.
twoq.go:222
↓ 2 callers
Method
Bytes
Bytes returns the Buffer's underlying byte slice. The returned slice is only valid before calling the Buffer's Close method. After that time, its cont
bufpool.go:51
↓ 2 callers
Method
Size
Size returns the total number of bytes in the LRU.
twoq.go:175
↓ 2 callers
Method
Stats
Stats returns the current stats for the given LRU.
stats.go:24
↓ 2 callers
Method
close
close closes the underlying bolt database and zeros the LRU. An LRU cannot be used after calling this method.
lru.go:111
↓ 2 callers
Method
deleteFromBolt
deleteFromBolt deletes the provided slice of keys from the bolt database and returns any error encountered.
boltcache.go:110
↓ 2 callers
Method
deleteReq
deleteReq safely deletes the request from the "reqs" map with the provided key.
lru.go:265
↓ 2 callers
Function
getBuf
getBuf retrieves a buffer from the pool.
bufpool.go:17
↓ 2 callers
Method
getStats
getStats returns the current LRU stats. Note: this method should only be called when the LRU mutex is locked!
stats.go:50
↓ 2 callers
Method
hitToMiss
hitToMiss registers that a retrieval attempt previously considered as a 'hit' was actually a 'miss' when trying to obtain the value from the database.
lru.go:193
↓ 2 callers
Method
prune
prune evicts items off of the back of the LRU if the LRU's size exceeds its capacity. It returns a slice of keys that have been evicted and the total
basiclru.go:117
↓ 2 callers
Function
putBuf
putBuf puts the provided buffer back into the pool.
bufpool.go:22
↓ 2 callers
Function
setTestStats
(l *LRU)
stats_test.go:43
↓ 2 callers
Function
stringFromWriterTo
(wt io.WriterTo)
lru_suite_test.go:38
↓ 2 callers
Function
verifyTestStats
(s Stats)
stats_test.go:55
↓ 1 callers
Method
Open
Open opens the LRU's remote store and, if successful, the local bolt database. If the bolt database contains existing items, the LRU is filled up to i
lru.go:92
↓ 1 callers
Method
ResetStats
ResetStats resets all stats to their initial state and returns the LRU's stats as they were immediately before being reset.
stats.go:32
↓ 1 callers
Method
addItem
addItem adds the provided key and size to the LRU. If there are any items that have been pruned, they will be deleted from the bolt database.
lru.go:285
↓ 1 callers
Method
evict
evict evicts items off of the back of the LRU until the LRU's size is less than or equal to the 'prune capacity'. It returns a slice of keys that have
basiclru.go:127
↓ 1 callers
Method
fillCacheFromBolt
fillCacheFromBolt fills the cache with all of the values currently in the bolt database. If the cache reaches its capacity, subsequent values are dele
boltcache.go:22
↓ 1 callers
Method
getResFromStore
getResFromStore attempts to retrieve the value from the remote store corresponding to the provided key. If the PostStoreFn is non-nil, it is called. I
lru.go:244
Function
BenchmarkBasicLRUGet
Benchmark getting an existing key with a BasicLRU.
basiclru_test.go:156
Function
BenchmarkBasicLRUPutAndEvict
Benchmark inserting/evicting items with a BasicLRU.
basiclru_test.go:167
Function
BenchmarkTwoQGet
Benchmark getting an existing key with a TwoQ LRU.
twoq_test.go:301
Function
BenchmarkTwoQPutAndEvict
Benchmark inserting/evicting items with a TwoQ LRU.
twoq_test.go:312
Method
Cap
Cap returns the total capacity of the LRU in bytes.
basiclru.go:79
Method
Cap
Cap returns the total capacity of the LRU in bytes.
twoq.go:165
Method
Close
Close closes the LRU's remote store and the connection to the local bolt database and returns any error encountered.
lru.go:101
Method
Close
()
store.go:30
Method
Close
()
lru_suite_test.go:57
Method
Close
()
lru_test.go:374
Method
Close
Close puts the underlying buffer back into the shared pool. The returned error is always nil.
bufpool.go:57
Method
Empty
Empty completely empties the cache and underlying bolt database.
lru.go:168
Method
Empty
Empty completely empties the LRU.
basiclru.go:94
Method
Empty
Empty empties all internal lists.
twoq.go:180
Method
Get
Get attempts to retrieve the value for the provided key. An error is returned if either no value exists or an error occurs while retrieving the value
lru.go:121
Method
Get
Get returns the size of the value corresponding to the provided key, or -1 if the key doesn't exist in the LRU.
basiclru.go:54
Method
Get
(key []byte)
store.go:22
Method
Get
(key []byte)
lru_suite_test.go:60
Method
Get
(k []byte)
lru_test.go:377
Method
Get
Get returns the size of the item identified by the provided key, or -1 if the key does not exist in the LRU.
algorithm.go:13
Method
Get
Get returns the size of the value corresponding to the provided key, or -1 if the key doesn't exist in the LRU.
twoq.go:110
Method
Len
Len returns the number of items in the LRU.
basiclru.go:84
Method
Len
Len returns the number of items in the LRU.
twoq.go:170
Method
Open
()
store.go:26
Method
Open
()
lru_suite_test.go:54
Method
Open
()
lru_test.go:371
Method
PutAndEvict
PutAndEvict inserts the provided key and value size into the LRU and returns a slice of keys that have been evicted and total bytes evicted.
basiclru.go:64
Method
PutAndEvict
PutAndEvict inserts the provided key and value size into the LRU and returns a slice of keys that have been evicted and total bytes evicted.
twoq.go:130
Method
PutOnStartup
PutOnStartup adds the provided key and value size into the LRU as an initial item. All items are inserted into the LRU until full, where items are dro
basiclru.go:103
Method
PutOnStartup
PutOnStartup adds the provided key and value size into the LRU as an initial item. All items are inserted into the warm LRU until full, where items be
twoq.go:191
Method
Size
Size returns the total number of bytes in the LRU.
basiclru.go:89
Function
TestLru
(t *testing.T)
lru_suite_test.go:11