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
19 changes: 9 additions & 10 deletions shard.go
Original file line number Diff line number Diff line change
Expand Up @@ -437,16 +437,11 @@ func initNewShard(config Config, callback onRemoveCallback, clock clock) *cacheS
if maximumShardSizeInBytes > 0 && bytesQueueInitialCapacity > maximumShardSizeInBytes {
bytesQueueInitialCapacity = maximumShardSizeInBytes
}
var hashmapStatsCapacity int
if config.StatsEnabled {
hashmapStatsCapacity = config.initialShardSize()
}
return &cacheShard{
hashmap: make(map[uint64]uint64, config.initialShardSize()),
hashmapStats: make(map[uint64]uint32, hashmapStatsCapacity),
entries: *queue.NewBytesQueue(bytesQueueInitialCapacity, maximumShardSizeInBytes, config.Verbose),
entryBuffer: make([]byte, config.MaxEntrySize+headersSizeInBytes),
onRemove: callback,
shard := &cacheShard{
hashmap: make(map[uint64]uint64, config.initialShardSize()),
entries: *queue.NewBytesQueue(bytesQueueInitialCapacity, maximumShardSizeInBytes, config.Verbose),
entryBuffer: make([]byte, config.MaxEntrySize+headersSizeInBytes),
onRemove: callback,

isVerbose: config.Verbose,
logger: newLogger(config.Logger),
Expand All @@ -455,4 +450,8 @@ func initNewShard(config Config, callback onRemoveCallback, clock clock) *cacheS
statsEnabled: config.StatsEnabled,
cleanEnabled: config.CleanWindow > 0,
}
if config.StatsEnabled {
shard.hashmapStats = make(map[uint64]uint32, config.initialShardSize())
}
return shard
}
Loading