fastcache icon indicating copy to clipboard operation
fastcache copied to clipboard

why fastcache not do hashcode collision?

Open ahfuzhang opened this issue 4 years ago • 1 comments

in file fastcache.go, func (b *bucket) Set, line 359: b.m[h] = idx | (b.gen << bucketSizeBits)

I think the code should be:

if oldValue, ok := b.m[h]; ok{
    //do something, or the last key of same hashcode will lost
}

thanks.

ahfuzhang avatar Jan 24 '22 06:01 ahfuzhang

sorry, I don't see all logic. If there is a check, clean() will not remove expires data. But we can still add a hashcode collision check, and tell calller the over write old value.

ahfuzhang avatar Jan 24 '22 08:01 ahfuzhang