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.org/project/CacheControl/>`__ library
so you can also use it as an HTTP cache with
`requests <https://pypi.org/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
Raw data
{
"_id": null,
"home_page": "https://github.com/calpaterson/pyappcache",
"name": "pyappcache",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": null,
"keywords": null,
"author": "Cal Paterson",
"author_email": "cal@calpaterson.com",
"download_url": "https://files.pythonhosted.org/packages/32/ad/799d8f8ac81270d3e6eecfe47ab2f74ebe28fc01c33d0848c6cf54c2781a/pyappcache-0.10.0.tar.gz",
"platform": null,
"description": "pyappcache\n==========\n\nPyappcache is a library to make it easier to use application-level\ncaching in Python.\n\n- Allows putting arbitrary Python objects into the cache\n- Uses PEP484 type hints to help you typecheck cache return values\n- Supports Memcache, Redis and SQLite\n- Supports working as a \"read-through\" and \"write-through\" cache\n- Native support for key `\"namespacing\" <https://github.com/memcached/memcached/wiki/ProgrammingTricks#namespacing>`__\n- Provides a few handy extras\n\n - A plugin for the\n `cachecontrol <https://pypi.org/project/CacheControl/>`__ library\n so you can also use it as an HTTP cache with\n `requests <https://pypi.org/project/requests/>`__\n\nA simple example\n----------------\n\n.. code:: python\n\n from datetime import date\n\n from pyappcache.redis import RedisCache\n from pyappcache.keys import Key, SimpleStringKey\n\n cache = RedisCache()\n\n # Annotate the type here to let mypy know this key is used for dates\n key: Key[date] = SimpleStringKey(\"mifid start date\")\n cache.set(key, date(2018, 1, 3), ttl_seconds=3600)\n\n ... # later...\n\n # This variable's type will be inferred as datetime.date\n special_date = cache.get(key)\n\n\nHow it compares to alternatives\n-------------------------------\n\nUsing the redis/memcache/sqlite client directly\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n- Explicit key objects allow for type inference and encapsulation of keying\n- Keys are prefix to help prevent collisions\n- Optional, pluggable, compression\n- Hopefully the overhead is small (not yet tested!)\n- Portable between redis/memcache/sqlite, etc\n\ndogpile.cache\n~~~~~~~~~~~~~\n\n- Explicit key objects allow for type inference and encapsulation of keying\n- dogpile.cache provides locking, pyappcache does not\n- Reduced temptation to use the problematic decorator pattern\n - This often causes import order problems as you need to have your cache at import time\n- Pyappache doesn't provide DBM/file backends, SQLite instead\n",
"bugtrack_url": null,
"license": null,
"summary": null,
"version": "0.10.0",
"project_urls": {
"Code": "https://github.com/calpaterson/pyappcache",
"Documentation": "https://pyappcache.readthedocs.io/en/latest/",
"Homepage": "https://github.com/calpaterson/pyappcache",
"Issue tracker": "https://github.com/calpaterson/pyappcache/issues"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "4b6b9afde80aa23c114b5272f5a827b0c5dd84af68bdc7d22005019c48938edc",
"md5": "972ece19400349ebf3f90c2005eadc27",
"sha256": "5bc70b56f157dd2dc894cb9b9873888659f5f5e8c372cccde2007846e1797b00"
},
"downloads": -1,
"filename": "pyappcache-0.10.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "972ece19400349ebf3f90c2005eadc27",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 27242,
"upload_time": "2024-04-05T10:48:50",
"upload_time_iso_8601": "2024-04-05T10:48:50.661549Z",
"url": "https://files.pythonhosted.org/packages/4b/6b/9afde80aa23c114b5272f5a827b0c5dd84af68bdc7d22005019c48938edc/pyappcache-0.10.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "32ad799d8f8ac81270d3e6eecfe47ab2f74ebe28fc01c33d0848c6cf54c2781a",
"md5": "a5261f2ede7a20bba77eaa1c4d7a4b44",
"sha256": "07548ead63c4e5212fd99173f9cff79cdcd65016ee058ac509c641127dafdac5"
},
"downloads": -1,
"filename": "pyappcache-0.10.0.tar.gz",
"has_sig": false,
"md5_digest": "a5261f2ede7a20bba77eaa1c4d7a4b44",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 29790,
"upload_time": "2024-04-05T10:48:52",
"upload_time_iso_8601": "2024-04-05T10:48:52.941182Z",
"url": "https://files.pythonhosted.org/packages/32/ad/799d8f8ac81270d3e6eecfe47ab2f74ebe28fc01c33d0848c6cf54c2781a/pyappcache-0.10.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-04-05 10:48:52",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "calpaterson",
"github_project": "pyappcache",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"tox": true,
"lcname": "pyappcache"
}