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 details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

Details for the file poche-1.0.0.tar.gz.

File metadata

  • Download URL: poche-1.0.0.tar.gz
  • Upload date:
  • Size: 15.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.4 CPython/3.9.1 Darwin/18.7.0

File hashes

Hashes for poche-1.0.0.tar.gz
Algorithm Hash digest
SHA256 596469ba9e21fa3a3ef2a2d4e88fa3f3a3e41fa1a6e9987dd9449edfb679158a
MD5 97a8a31ac9140314d8366bec359e00fe
BLAKE2b-256 43d69071e24d7f88c1a3433eac1cc90f9bf3f57fdf470b20bfb0304e03e64866

See more details on using hashes here.

File details

Details for the file poche-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: poche-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 16.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.4 CPython/3.9.1 Darwin/18.7.0

File hashes

Hashes for poche-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2ab3fb399045320c1aec4c218b74face358ea46fccadc05a1e7a949046d9c53e
MD5 dd6caff297cfacfdaab13eedfc38cb59
BLAKE2b-256 acbf2eb57a97280c045c0e457cdecdef458005f8320f48887af46dab275c3de3

See more details on using hashes here.

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