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

    • And provides type hints so you can typecheck what you get back from the cache
  • 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

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

client = redis.Redis()
cache = RedisCache(client)

# Annotate the type here to let mypy know this key is used for dates
key: Key[date] = GenericStringKey("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
- Key prefixing
- Optional 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
- As yet there is no locking in pyappcache
- Reduced temptation to use the problematic decorator pattern
  - This often causes import order problems as you need to have your cache at import time
- SQLite backend instead of DBM/file backends


Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

pyappcache-0.2-py3-none-any.whl (11.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pyappcache-0.2-py3-none-any.whl
  • Upload date:
  • Size: 11.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/47.3.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.7.3

File hashes

Hashes for pyappcache-0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 33b88b9da333c69a91e2650add316bcd4e06aabf19437e3d1e61c8f96b71a7ea
MD5 be265dd519d165bcc048de2b0efb6812
BLAKE2b-256 4d80b1ac06845b7a12f70b3c323ddd33d2cff7979f3a13bf08d6151f49baf65a

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