Skip to main content

jitcache is a just-in-time key-value cache that is thread/process safe

Project description

Build Status Documentation Status

jitcache

jitcache is a just-in-time key-value cache that is thread/process safe. jitcache also prevents repeated computation when multiple workers request the same value.

jitcache was designed to improve the performance of Plot.ly Dash apps by caching results and reducing CPU load.

jitcache is a just-in-time key-value cache that is thread/process safe. jitcache also prevents repeated computation when multiple workers request the same value.

jitcache was designed to improve the performance of Plot.ly Dash apps by caching results and reducing CPU load.

Installation

Install via pip::

$ pip install jitcache

Documentation

Full documentation available here https://jitcache.readthedocs.io/

Example Usage

Notice that slow_fn is only called once, despite two requests.

from cache import KVStore
import time
import json

store = KVStore()

def slow_fn(input_1, input_2):
    print("Slow Function Called")
    time.sleep(1)
    return input_1 * input_2

kwarg_dict = {
    'input_1': 10,
    'input_2': 4
}

# Make a unique identifier for this object
key = json.dumps(kwarg_dict, sort_keys=True)

# Insert a value with corresponding key
value1 = store.get_value(key, slow_fn, kwarg_dict)

value2 = store.get_value(key, slow_fn, kwarg_dict)

print(value1), print(value2)

Output:

Slow Function Called
40
40

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

jitcache-0.2-py3-none-any.whl (3.3 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