Skip to content

Commit fee9b2b

Browse files
authored
Merge branch 'main' into dependabot/github_actions/toolmantim/release-drafter-6.1.0
2 parents bf261e6 + 353ff50 commit fee9b2b

3 files changed

Lines changed: 8 additions & 5 deletions

File tree

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515

1616
steps:
1717
- name: Set up Go
18-
uses: actions/setup-go@v5
18+
uses: actions/setup-go@v6
1919
with:
2020
go-version: ${{matrix.go}}
2121
id: go

bigcache_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,6 @@ func TestTimingEviction(t *testing.T) {
256256
cache.Set("key", []byte("value"))
257257

258258
// when
259-
clock.set(1)
260259
cache.Set("key2", []byte("value2"))
261260
_, err := cache.Get("key")
262261

@@ -1181,7 +1180,7 @@ func TestBigCache_GetWithInfo(t *testing.T) {
11811180
name: "Expired",
11821181
clock: 5,
11831182
wantData: value,
1184-
wantResp: Response{},
1183+
wantResp: Response{EntryStatus: Expired},
11851184
},
11861185
{
11871186
name: "After Expired",

shard.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ func (s *cacheShard) isExpired(oldestEntry []byte, currentTimestamp uint64) bool
286286
if currentTimestamp <= oldestTimestamp { // if currentTimestamp < oldestTimestamp, the result will out of uint64 limits;
287287
return false
288288
}
289-
return currentTimestamp-oldestTimestamp > s.lifeWindow
289+
return currentTimestamp-oldestTimestamp >= s.lifeWindow
290290
}
291291

292292
func (s *cacheShard) cleanUp(currentTimestamp uint64) {
@@ -437,9 +437,13 @@ func initNewShard(config Config, callback onRemoveCallback, clock clock) *cacheS
437437
if maximumShardSizeInBytes > 0 && bytesQueueInitialCapacity > maximumShardSizeInBytes {
438438
bytesQueueInitialCapacity = maximumShardSizeInBytes
439439
}
440+
var hashmapStatsCapacity int
441+
if config.StatsEnabled {
442+
hashmapStatsCapacity = config.initialShardSize()
443+
}
440444
return &cacheShard{
441445
hashmap: make(map[uint64]uint64, config.initialShardSize()),
442-
hashmapStats: make(map[uint64]uint32, config.initialShardSize()),
446+
hashmapStats: make(map[uint64]uint32, hashmapStatsCapacity),
443447
entries: *queue.NewBytesQueue(bytesQueueInitialCapacity, maximumShardSizeInBytes, config.Verbose),
444448
entryBuffer: make([]byte, config.MaxEntrySize+headersSizeInBytes),
445449
onRemove: callback,

0 commit comments

Comments
 (0)