Skip to main content

No project description provided

Project description

pyappcache

Pyappcache is a library to make it easier to use application-level caching in Python.

  • Allows putting arbitrary Python objects into the cache

  • Uses PEP484 type hints to help you typecheck cache return values

  • Supports Memcache, Redis and SQLite

  • Supports working as a "read-through" and "write-through" cache

  • Native support for key "namespacing" <https://github.com/memcached/memcached/wiki/ProgrammingTricks#namespacing>__

  • Provides a few handy extras

    • A plugin for the cachecontrol <https://pypi-hypernode.com/project/CacheControl/>__ library so you can also use it as an HTTP cache with requests <https://pypi-hypernode.com/project/requests/>__

A simple example

.. code:: python

from datetime import date

from pyappcache.redis import RedisCache
from pyappcache.keys import Key, SimpleStringKey

cache = RedisCache()

# Annotate the type here to let mypy know this key is used for dates
key: Key[date] = SimpleStringKey("mifid start date")
cache.set(key, date(2018, 1, 3), ttl_seconds=3600)

... # later...

# This variable's type will be inferred as datetime.date
special_date = cache.get(key)

How it compares to alternatives

Using the redis/memcache/sqlite client directly


- Explicit key objects allow for type inference and encapsulation of keying
- Keys are prefix to help prevent collisions
- Optional, pluggable, compression
- Hopefully the overhead is small (not yet tested!)
- Portable between redis/memcache/sqlite, etc

dogpile.cache
~~~~~~~~~~~~~

- Explicit key objects allow for type inference and encapsulation of keying
- dogpile.cache provides locking, pyappcache does not
- Reduced temptation to use the problematic decorator pattern
  - This often causes import order problems as you need to have your cache at import time
- Pyappache doesn't provide DBM/file backends, SQLite instead

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

pyappcache-0.9.1.tar.gz (22.1 kB view details)

Uploaded Source

Built Distribution

pyappcache-0.9.1-py3-none-any.whl (23.6 kB view details)

Uploaded Python 3

File details

Details for the file pyappcache-0.9.1.tar.gz.

File metadata

  • Download URL: pyappcache-0.9.1.tar.gz
  • Upload date:
  • Size: 22.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.8

File hashes

Hashes for pyappcache-0.9.1.tar.gz
Algorithm Hash digest
SHA256 1c0f563447c0bb08b38b7228c71a5d2f1b245c80c96dc56ca6c1bda8f6bd56b5
MD5 79c944232a9d6eea25c19c7110c6dc0e
BLAKE2b-256 992657696745f74561aca4c66c9b920486039a4d9d1f978d6e36fb2ff9977719

See more details on using hashes here.

File details

Details for the file pyappcache-0.9.1-py3-none-any.whl.

File metadata

  • Download URL: pyappcache-0.9.1-py3-none-any.whl
  • Upload date:
  • Size: 23.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.8

File hashes

Hashes for pyappcache-0.9.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c55e52ed5b4a4390ed62f1bb16b876547ec99b202a8662929a4e4ec93e22a136
MD5 8c19bc287803d86c432ed0eed63d1c47
BLAKE2b-256 6f8ebcf035c82269d0dcac42d0238d4b184bde105c1931fd24d793e192067865

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