We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
What is the issue you are having? Reset shards no longer works
What is BigCache doing that it shouldn't? Empty the shards.
Using stats method i can see the how many items are in cache
cache, initErr := bigcache.NewBigCache(config) cache.Stats() Output: {"hits":1222,"misses":2,"delete_hits":0,"delete_misses":0,"collisions":0}
but when i run the method Reset to flush the shards, they are not flushed / empty, , in previously versions this method works correctly.
cache, initErr := bigcache.NewBigCache(config) cache.Reset()
After i run the Reset() the stats are se same Output: {"hits":1222,"misses":2,"delete_hits":0,"delete_misses":0,"collisions":0}
Output: {"hits":1222,"misses":2,"delete_hits":0,"delete_misses":0,"collisions":0}
Environment:
/etc/os-release
The text was updated successfully, but these errors were encountered:
Hi, I created following tests and it looks like stats were never cleared. What version do you mean in this sentence:
in previously versions this method works correctly
package bigcache import ( "fmt" "testing" "time" ) func TestCacheReset322(t *testing.T) { t.Parallel() // given cache, _ := NewBigCache(Config{ Shards: 8, LifeWindow: time.Second, MaxEntriesInWindow: 1, MaxEntrySize: 256, }) keys := 1337 // when for i := 0; i < keys; i++ { cache.Set(fmt.Sprintf("key%d", i), []byte("value")) cache.Get(fmt.Sprintf("key%d", i)) } // then if int64(keys) != cache.Stats().Hits { t.Error("Stats not set") } // and when cache.Reset() // then if int64(0) != cache.Stats().Hits { t.Error("Stats not cleared") } }
Sorry, something went wrong.
Hello, I think this problem is because Reset() did not reset the cacheShard.Stats
func (c *BigCache) Reset() error { for _, shard := range c.shards { shard.reset(c.config) } return nil } func (s *cacheShard) reset(config Config) { s.lock.Lock() s.hashmap = make(map[uint64]uint32, config.initialShardSize()) s.entryBuffer = make([]byte, config.MaxEntrySize+headersSizeInBytes) s.entries.Reset() s.lock.Unlock() }
No branches or pull requests
What is the issue you are having?
Reset shards no longer works
What is BigCache doing that it shouldn't?
Empty the shards.
Using stats method i can see the how many items are in cache
but when i run the method Reset to flush the shards, they are not flushed / empty, , in previously versions this method works correctly.
After i run the Reset() the stats are se same
Output: {"hits":1222,"misses":2,"delete_hits":0,"delete_misses":0,"collisions":0}
Environment:
/etc/os-release
or winver.exe): Debian GNU/Linux 10 (buster)The text was updated successfully, but these errors were encountered: