Skip to main content

A Python decorator library for caching function results in MongoDB

Project description

https://badge.fury.io/py/mongo-memoize.png https://travis-ci.org/ikuyamada/mongo-memoize.png?branch=master

A Python decorator library for instantly caching function results in MongoDB.

Basic Usage

from mongo_memoize import memoize

@memoize()
def func():
    ...

Customization

You can specify custom serializer and key_generator. serializer is used to serialize function results in order to convert them into formats that can be stored in MongoDB. key_generator generates a cache key from the function arguments. PickleSerializer and PickleMD5KeyGenerator are used by default.

from mongo_memoize import memoize, NoopSerializer, PickleMD5KeyGenerator

@memoize(serializer=NoopSerializer(), key_generator=PickleMD5KeyGenerator())
def func():
    ...

Using Capped Collection

Capped collection is a MongoDB feature which allows to limit the maximum size of the collection. By setting capped=True, a capped collection is created automatically.

from mongo_memoize import memoize

@memoize(capped=True, capped_size=100000000)
def func():
    ...

Documentation

http://mongo-memoize.readthedocs.org/

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

mongo-memoize-0.0.4.tar.gz (4.3 kB view details)

Uploaded Source

File details

Details for the file mongo-memoize-0.0.4.tar.gz.

File metadata

File hashes

Hashes for mongo-memoize-0.0.4.tar.gz
Algorithm Hash digest
SHA256 c1500e25f2ca54be0fae5f3631db7ce3be0e92daa3e66d665dbe8b4c316b8130
MD5 377cbaa6b104e63e10b73421c01ea935
BLAKE2b-256 9ccfd1a17858125f66ccce612c94bdfc8a41d118d676b3197e004cc8f318738b

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