Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion shard.go
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,10 @@ func (s *cacheShard) del(hashedKey uint64) error {

func (s *cacheShard) onEvict(oldestEntry []byte, currentTimestamp uint64, evict func(reason RemoveReason) error) bool {
oldestTimestamp := readTimestampFromEntry(oldestEntry)
if currentTimestamp-oldestTimestamp > s.lifeWindow {
keyHash := readHashFromEntry(oldestEntry)
if keyHash == 0 || (currentTimestamp >= oldestTimestamp &&
currentTimestamp-oldestTimestamp > s.lifeWindow) {

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add a test for it?

evict(Expired)
return true
}
Expand Down