MCPcopy
hub / github.com/go-gorm/gorm / addToBucket

Method addToBucket

internal/lru/lru.go:342–349  ·  view source on GitHub ↗

addToBucket adds entry to expire bucket so that it will be cleaned up when the time comes. Has to be called with lock!

(e *Entry[K, V])

Source from the content-addressed store, hash-verified

340
341// addToBucket adds entry to expire bucket so that it will be cleaned up when the time comes. Has to be called with lock!
342func (c *LRU[K, V]) addToBucket(e *Entry[K, V]) {
343 bucketID := (numBuckets + c.nextCleanupBucket - 1) % numBuckets
344 e.ExpireBucket = bucketID
345 c.buckets[bucketID].entries[e.Key] = e
346 if c.buckets[bucketID].newestEntry.Before(e.ExpiresAt) {
347 c.buckets[bucketID].newestEntry = e.ExpiresAt
348 }
349}
350
351// removeFromBucket removes the entry from its corresponding bucket. Has to be called with lock!
352func (c *LRU[K, V]) removeFromBucket(e *Entry[K, V]) {

Callers 1

AddMethod · 0.95

Calls 1

BeforeMethod · 0.45

Tested by

no test coverage detected