Skip to content
New issue

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

How to clear cache? #46

Open
comerc opened this issue May 12, 2017 · 3 comments
Open

How to clear cache? #46

comerc opened this issue May 12, 2017 · 3 comments

Comments

@comerc
Copy link
Contributor

comerc commented May 12, 2017

No description provided.

@olehreznichenko
Copy link

I used this

const someStore = new Map

function test(keys) {  }
memoize(test, {
  cache: {
    create() {
      const store = someStore
        return {
	  has(key) {
	    return store.has(key)
	  },
	  get(key) {
	    return store.get(key)
	  },
	  set(key, value) {
	   store.set(key, value)
	  }
	}
    }
  }
})

someStore.clear()

@mriedem
Copy link

mriedem commented Feb 2, 2021

Should this issue be closed? Or are there more details on how/when you'd want to clear the cache?

I don't see any options for putting timers on the cache to age out entries so maybe that's an idea for this issue. If I were to do that I'd probably just write a custom cache where the set function uses setTimeout for my timer and then that clears the cache for the given entry when the timer fires. Is that pretty common with users of this library (I'm new to it).

@ecerroni
Copy link

ecerroni commented Feb 5, 2021

If you set the cache like here #16 (comment) then you can use keyv's clear method to reset the store.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants