diff --git a/encoding.go b/encoding.go index fc861251..8d231ae8 100644 --- a/encoding.go +++ b/encoding.go @@ -78,6 +78,6 @@ func readHashFromEntry(data []byte) uint64 { return binary.LittleEndian.Uint64(data[timestampSizeInBytes:]) } -func resetKeyFromEntry(data []byte) { +func resetHashFromEntry(data []byte) { binary.LittleEndian.PutUint64(data[timestampSizeInBytes:], 0) } diff --git a/shard.go b/shard.go index e80a759a..3d5e40d6 100644 --- a/shard.go +++ b/shard.go @@ -124,7 +124,7 @@ func (s *cacheShard) set(key string, hashedKey uint64, entry []byte) error { if previousIndex := s.hashmap[hashedKey]; previousIndex != 0 { if previousEntry, err := s.entries.Get(int(previousIndex)); err == nil { - resetKeyFromEntry(previousEntry) + resetHashFromEntry(previousEntry) //remove hashkey delete(s.hashmap, hashedKey) } @@ -176,7 +176,7 @@ func (s *cacheShard) addNewWithoutLock(key string, hashedKey uint64, entry []byt func (s *cacheShard) setWrappedEntryWithoutLock(currentTimestamp uint64, w []byte, hashedKey uint64) error { if previousIndex := s.hashmap[hashedKey]; previousIndex != 0 { if previousEntry, err := s.entries.Get(int(previousIndex)); err == nil { - resetKeyFromEntry(previousEntry) + resetHashFromEntry(previousEntry) } } @@ -265,7 +265,7 @@ func (s *cacheShard) del(hashedKey uint64) error { if s.statsEnabled { delete(s.hashmapStats, hashedKey) } - resetKeyFromEntry(wrappedEntry) + resetHashFromEntry(wrappedEntry) } s.lock.Unlock() @@ -332,7 +332,7 @@ func (s *cacheShard) removeOldestEntry(reason RemoveReason) error { if err == nil { hash := readHashFromEntry(oldest) if hash == 0 { - // entry has been explicitly deleted with resetKeyFromEntry, ignore + // entry has been explicitly deleted with resetHashFromEntry, ignore return nil } delete(s.hashmap, hash)