From ed59b718d23c9b63870a7933f33b3dbe2b340152 Mon Sep 17 00:00:00 2001 From: raeidish <118611562+raeidish@users.noreply.github.com> Date: Tue, 17 Oct 2023 14:47:06 +0200 Subject: [PATCH] changed to uint64 keys (#377) --- shard.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/shard.go b/shard.go index f4d2400b..4f03b53e 100644 --- a/shard.go +++ b/shard.go @@ -16,7 +16,7 @@ type Metadata struct { } type cacheShard struct { - hashmap map[uint64]uint32 + hashmap map[uint64]uint64 entries queue.BytesQueue lock sync.RWMutex entryBuffer []byte @@ -140,7 +140,7 @@ func (s *cacheShard) set(key string, hashedKey uint64, entry []byte) error { for { if index, err := s.entries.Push(w); err == nil { - s.hashmap[hashedKey] = uint32(index) + s.hashmap[hashedKey] = uint64(index) s.lock.Unlock() return nil } @@ -164,7 +164,7 @@ func (s *cacheShard) addNewWithoutLock(key string, hashedKey uint64, entry []byt for { if index, err := s.entries.Push(w); err == nil { - s.hashmap[hashedKey] = uint32(index) + s.hashmap[hashedKey] = uint64(index) return nil } if s.removeOldestEntry(NoSpace) != nil { @@ -188,7 +188,7 @@ func (s *cacheShard) setWrappedEntryWithoutLock(currentTimestamp uint64, w []byt for { if index, err := s.entries.Push(w); err == nil { - s.hashmap[hashedKey] = uint32(index) + s.hashmap[hashedKey] = uint64(index) return nil } if s.removeOldestEntry(NoSpace) != nil { @@ -347,7 +347,7 @@ func (s *cacheShard) removeOldestEntry(reason RemoveReason) error { func (s *cacheShard) reset(config Config) { s.lock.Lock() - s.hashmap = make(map[uint64]uint32, config.initialShardSize()) + s.hashmap = make(map[uint64]uint64, config.initialShardSize()) s.entryBuffer = make([]byte, config.MaxEntrySize+headersSizeInBytes) s.entries.Reset() s.lock.Unlock() @@ -438,7 +438,7 @@ func initNewShard(config Config, callback onRemoveCallback, clock clock) *cacheS bytesQueueInitialCapacity = maximumShardSizeInBytes } return &cacheShard{ - hashmap: make(map[uint64]uint32, config.initialShardSize()), + hashmap: make(map[uint64]uint64, config.initialShardSize()), hashmapStats: make(map[uint64]uint32, config.initialShardSize()), entries: *queue.NewBytesQueue(bytesQueueInitialCapacity, maximumShardSizeInBytes, config.Verbose), entryBuffer: make([]byte, config.MaxEntrySize+headersSizeInBytes),