lonelyenvoy / python-memoization

A powerful caching library for Python, with TTL support and multiple algorithm options.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

remove particular element from cache?

rmrmg opened this issue · comments

Hello I have function which can return results or timeout, simplified example is below:

@cache()
def longjob(args):
   try:
      data =  getdata(args)
      return data
  except timeout:
      return 'data not available try again later'

When function cannot return data there is no reason to cache result. Is there any way to remove single entry from cache? I am aware of clear_cache() but this remove all cached values.

Feature implemented in v0.4.0. Now available at PyPI or GitHub Releases.

Please upgrade by: pip install -U memoization

Use this API: cache_remove_if(predicate)