MCPcopy
hub / github.com/coocood/freecache / GetWithExpiration

Method GetWithExpiration

cache.go:264–271  ·  view source on GitHub ↗

GetWithExpiration returns the value with expiration or not found error.

(key []byte)

Source from the content-addressed store, hash-verified

262
263// GetWithExpiration returns the value with expiration or not found error.
264func (cache *Cache) GetWithExpiration(key []byte) (value []byte, expireAt uint32, err error) {
265 hashVal := hashFunc(key)
266 segID := hashVal & segmentAndOpVal
267 cache.locks[segID].Lock()
268 value, expireAt, err = cache.segments[segID].get(key, nil, hashVal, false)
269 cache.locks[segID].Unlock()
270 return
271}
272
273// GetWithExpirationAndBuf copies the value to the buf and gets with expiration or returns a not found error.
274// This method doesn't allocate memory when the capacity of buf is greater or equal to value.

Callers 3

GetIntWithExpirationMethod · 0.95
TestGetWithExpirationFunction · 0.95

Calls 2

hashFuncFunction · 0.85
getMethod · 0.80

Tested by 2

TestGetWithExpirationFunction · 0.76