Git Product home page Git Product logo

Comments (7)

gaozhenyusky avatar gaozhenyusky commented on May 29, 2024

Or in other words, Is there something wrong with my conf ?

from bigcache.

janisz avatar janisz commented on May 29, 2024

Does it expire after 1 hour? If so then set LifeWindow: 0 and that will prevent eviction.

// Time after which entry can be evicted

from bigcache.

gaozhenyusky avatar gaozhenyusky commented on May 29, 2024

oh thx, I will try it, i think u can supplement some annotation on LifeWindow, like If set to <= 0 then no action is performed

from bigcache.

janisz avatar janisz commented on May 29, 2024

I double checked on this and it looks like in your case it wont work. 0 means everything will be imiedietally evicted so you need to use some bigger value.

from bigcache.

gaozhenyusky avatar gaozhenyusky commented on May 29, 2024

I double checked on this and it looks like in your case it wont work. 0 means everything will be imiedietally evicted so you need to use some bigger value.

wow, i update LifeWindow: 10 * 365 * 24 * time.Hour and try it again.
Actually in my project i just want use bigCache like Map now, Whether to add a property in bigcache.Config like NeverLost ?

from bigcache.

janisz avatar janisz commented on May 29, 2024

It's complicated. In your configuration you have LifeWindow and HardMaxCacheSize. What bigcache should do if you need more memory than HardMaxCacheSize? Currently it will evict the oldest entry and replace it with new one. You can set HardMaxCacheSize to 0 to allow it growing infinitely but I don't recommend that :)

bigcache/config.go

Lines 25 to 32 in 982ec3b

// HardMaxCacheSize is a limit for BytesQueue size in MB.
// It can protect application from consuming all available memory on machine, therefore from running OOM Killer.
// Default value is 0 which means unlimited size. When the limit is higher than 0 and reached then
// the oldest entries are overridden for the new ones. The max memory consumption will be bigger than
// HardMaxCacheSize due to Shards' s additional memory. Every Shard consumes additional memory for map of keys
// and statistics (map[uint64]uint32) the size of this map is equal to number of entries in
// cache ~ 2×(64+32)×n bits + overhead or map itself.
HardMaxCacheSize int

from bigcache.

gaozhenyusky avatar gaozhenyusky commented on May 29, 2024

thx, u r right :)

from bigcache.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.