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)
| 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. |
| 275 | func (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. |
| 285 | func (cache *Cache) TTL(key []byte) (timeLeft uint32, err error) { |