Switch branches/tags
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
72 lines (45 sloc) 1.92 KB

Welcome to mongo-memoize's documentation!

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

Basic Usage

from mongo_memoize import memoize

def func():


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. :class:`PickleSerializer <mongo_memoize.PickleSerializer>` and :class:`PickleMD5KeyGenerator <mongo_memoize.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():

For further information, please refer the :doc:`api`.


.. toctree::
   :maxdepth: 2


Indices and tables