Skip to content

Commit

Permalink
Fix: cache overflow (#238)
Browse files Browse the repository at this point in the history
  • Loading branch information
aopoltorzhicky committed Jul 4, 2024
1 parent 02183f5 commit b21bdae
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cmd/api/cache/ttl.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func (c *TTLCache) Set(key string, data []byte) {
c.queue[queueIdx-1] = key
delete(c.m, keyForRemove)
} else {
c.queue[c.maxEntitiesCount-queueIdx-1] = key
c.queue[queueIdx] = key
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions cmd/api/cache/ttl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ func TestTTLCache_SetGet(t *testing.T) {

_, exists := c.Get("0")
require.False(t, exists)

require.Equal(t, []string{"98", "99"}, c.queue)
})

t.Run("overflow set queue multithread", func(t *testing.T) {
Expand Down

0 comments on commit b21bdae

Please sign in to comment.