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

Method GetWithExpirationAndBuf

cache.go:275–282  ·  view source on GitHub ↗

GetWithExpirationAndBuf copies the value to the buf and gets with expiration or returns a not found error. This method doesn't allocate memory when the capacity of buf is greater or equal to value.

(key []byte, buf []byte)

Source from the content-addressed store, hash-verified

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.
275func (cache *Cache) GetWithExpirationAndBuf(key []byte, buf []byte) (value []byte, expireAt uint32, err error) {
276 hashVal := hashFunc(key)
277 segID := hashVal & segmentAndOpVal
278 cache.locks[segID].Lock()
279 value, expireAt, err = cache.segments[segID].get(key, buf, hashVal, false)
280 cache.locks[segID].Unlock()
281 return
282}
283
284// TTL returns the TTL time left for a given key or a not found error.
285func (cache *Cache) TTL(key []byte) (timeLeft uint32, err error) {

Callers 1

Calls 2

hashFuncFunction · 0.85
getMethod · 0.80

Tested by 1