Skip to main content

Adds function memoization support

Project description

mezmorize

travis

versions pypi

license

A python function memoization library heavily inspired by Flask-Cache.

This is a fork of the Flask-Cache extension.

Setup

mezmorize is available on PyPI and can be installed with:

pip install mezmorize

Usage

from random import randrange

from mezmorize import Cache

cache = Cache(CACHE_TYPE='simple')


@cache.memoize(60)
def add(a, b):
    return a + b + randrange(0, 1000)

# Initial
add(2, 5)

# Memoized
add(2, 5)
add(2, 5)

# Delete cache
cache.delete_memoized(add)

# Initial
add(2, 5)

For more configuration options, check out the the examples or Flask-Caching documentation.

Compatibility with Flask-Cache and Flask-Caching

There are no known incompatibilities or breaking changes between either the latest Flask-Cache v0.13 or Flask-Caching v1.8.0 and the current version of mezmorize.

Python versions

Starting with version 0.26.0, mezmorize dropped Python 2 support. The library is tested against Python 3.6, 3.7, 3.8, and PyPy 3.6.

Environment Variables

  • CACHE_DIR: the directory your cache will be stored in. The default is the cache dir in the current folder.

Links

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 mezmorize, version 0.28.2
Filename, size File type Python version Upload date Hashes
Filename, size mezmorize-0.28.2-py2.py3-none-any.whl (14.2 kB) File type Wheel Python version py2.py3 Upload date Hashes View
Filename, size mezmorize-0.28.2.tar.gz (25.6 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page