GithubHelp home page GithubHelp logo

items never expire? about bigcache HOT 4 CLOSED

allegro avatar allegro commented on May 16, 2024
items never expire?

from bigcache.

Comments (4)

shiftregister-vg avatar shiftregister-vg commented on May 16, 2024 3

@unisqu I missed it too, you need to also set CleanWindow in your config.

Here's a config that I'm using that does expire items after 30 minutes

cacheConfig := bigcache.Config {
    Shards: 1024,
    LifeWindow: 30 * time.Minute,
    CleanWindow: 30 * time.Minute,
    MaxEntriesInWindow: 1000 * 30 * 60,
    MaxEntrySize: 500,
    Verbose: true,
    HardMaxCacheSize: 1024,
    OnRemove: nil,
    Logger: cacheLog,
}

from bigcache.

cristaloleg avatar cristaloleg commented on May 16, 2024

Hi, can you show your code? It's hard to guess what you're doing 😉

from bigcache.

siennathesane avatar siennathesane commented on May 16, 2024

Closing as resolved. :)

from bigcache.

bonedaddy avatar bonedaddy commented on May 16, 2024

im getting this error too, I have set a clean window to 1hr, and a lifetime of 12hr, but content is not getting cleaned.

Code:

// NewCache is used to instantiate our bigcache content cache
func NewCache(opts config.Cache) (*Cache, error) {
	// parse content life time into time.Duration
	lifetime, err := time.ParseDuration(opts.Content.LifeTime)
	if err != nil {
		return nil, err
	}
	// parse cache clean window into time.Duration
	cleanwindow, err := time.ParseDuration(opts.Content.CleanWindow)
	if err != nil {
		return nil, err
	}
	// generate a default bigcache config
	cfg := bigcache.DefaultConfig(lifetime)
	// set the maximum size of the cache in megabytes
	cfg.HardMaxCacheSize = opts.Content.MaxSizeInMB
	// set how often we should attempt to clean the cache
	cfg.CleanWindow = cleanwindow
	// instantiate our bigcache
	bc, err := bigcache.NewBigCache(cfg)
	if err != nil {
		return nil, err
	}
	// return the content cache
	return &Cache{
		bc,
	}, nil
}

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.