Skip to main content

This module caches the result of function.

Project description

description

This module caches the processing result of the function in the storage, and if the cache hits, skips the processing in the function and returns the result. Create “.object_cache” in the current path and cache it.

install

pip install object-cache

code example

import time

from object_cache import object_cache


@object_cache
def factorial(a):
    result = 1
    for i in range(2, a + 1):
        result *= i

    return result


for _ in range(5):
    start = time.time()
    factorial(100000)
    print("elapsed time", time.time() - start)

clear cache

rm -fr .object_cache

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

object-cache-0.1.6.tar.gz (2.7 kB view hashes)

Uploaded Source

Built Distribution

object_cache-0.1.6-py3-none-any.whl (2.9 kB view hashes)

Uploaded Python 3

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