Skip to main content

Simple and fast Python in-memory caching library

Project description

poche

Build Status Codecov Checked with mypy Code style: black

Simple and fast Python in-memory caching with support for TTLs.

Meant to speed up using dictionaries as cache backend for simple usecases.

No external dependencies, 100% code coverage and static type checked.

Installation

Requires Python 3.6+.

pip install poche

Roadmap

v1:

  • Basic TTL
  • get
  • set
  • getset
  • flush

v1.1:

  • expire
  • persist
  • rename

v1.2:

  • getorset with callback

Example

from time import sleep

import poche

>>> c = poche.Cache()

>>> c.set("one", "uno")
>>> c.get("one")
"uno"

>>> c.get("two")
None
>>> c.getset("two", "dos")
None
>>> c.get("two")
"dos"

>>> c.set("three", "tres", ttl=2)
>>> c.get("three")
"tres"
>>> sleep(2)
>>> c.get("three")
None

>>> c = poche.Cache(ttl=2)  # you can also define a default TTL

>>> c.set("four", "cuatro")
>>> c.get("four")
"cuatro"
>>> sleep(2)
>>> c.get("four")
None

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

poche-1.0.0.tar.gz (15.8 kB view hashes)

Uploaded Source

Built Distribution

poche-1.0.0-py3-none-any.whl (16.1 kB view hashes)

Uploaded 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