Skip to main content

Cache any python object to file using improved pickling .

Project description

https://badge.fury.io/py/anycache.svg https://travis-ci.org/c0fec0de/anycache.svg?branch=master https://coveralls.io/repos/github/c0fec0de/anycache/badge.svg https://readthedocs.org/projects/anycache/badge/?version=2.0.7 https://codeclimate.com/github/c0fec0de/anycache.png https://img.shields.io/pypi/pyversions/anycache.svg https://landscape.io/github/c0fec0de/anycache/master/landscape.svg?style=flat https://img.shields.io/badge/code%20style-pep8-brightgreen.svg https://img.shields.io/badge/code%20style-pep257-brightgreen.svg

Cache any python object to file using improved pickling

Getting started

To cache the result of a function, use the global unlimited anycache:

>>> from anycache import anycache
>>> @anycache()
... def myfunc(posarg, kwarg=3):
...     print("  Calcing %r + %r = %r" % (posarg, kwarg, posarg + kwarg))
...     return posarg + kwarg
>>> myfunc(8, 5)
  Calcing 8 + 5 = 13
13
>>> myfunc(8, 5)
13

anycache caches nearly any python object. Also lambda statements. It uses Dill as backend. An improved version of pythons build-in pickle.

To preserve the result between multiple python runs, a persistent cache directory needs to be set.

>>> from anycache import anycache
>>> @anycache(cachedir='/tmp/anycache.my')
... def myfunc(posarg, kwarg=3):
...     return posarg + kwarg

The AnyCache object serves additional functions for cache clearing and size handling.

Installation

To install the anycache module run:

pip install anycache

If you do not have write-permissions to the python installation, try:

pip install anycache --user

Project details


Download files

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

Files for anycache, version 2.0.7
Filename, size File type Python version Upload date Hashes
Filename, size anycache-2.0.7-py2.py3-none-any.whl (10.3 kB) File type Wheel Python version py2.py3 Upload date Hashes View
Filename, size anycache-2.0.7.tar.gz (6.5 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page