Skip to main content

Combination of weakref cache and LRU cache.

Project description

weaklru

Simple combination of a weakref cache and a lru cache.


class Obj:
  pass


l = WeakLRU(max_size=2)

l.set("a", Obj())
l.set("b", Obj())
l.set("c", Obj())
l.get(a)        # none
l.get(b)        # obj
l.get(c)        # obj

You can add objects to the cache, and they will never expire as long as they are being used.

Also, a maximum number of objects will be stored in the LRU portion of the cache.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

weaklru-0.1.1.tar.gz (2.7 kB view hashes)

Uploaded Source

Built Distribution

weaklru-0.1.1-py2.py3-none-any.whl (3.6 kB view hashes)

Uploaded Python 2 Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page