From c485f0806c5e98352bd318e544888faad5d37f0b Mon Sep 17 00:00:00 2001 From: yangtaoran Date: Fri, 5 May 2023 17:21:56 +0800 Subject: [PATCH] rename resetKeyFromEntry --- encoding.go | 2 +- shard.go | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) 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)