Skip to main content

A simple package for caching python objects.

Project description

Cacheasy

This is a simple utility Python package for caching Python objects. Makes use of the pickle standard library and simply stores files in a folder called cache. If you want to use another location, you can specify cache_folderpath in a .env file.

Writing to cache

import cacheasy
x = 5
cacheasy.write_to_cache(x, 'my_cool_x')

Reading from cache

import cacheasy
x = cacheasy.read_from_cache('my_cool_x')

Common usage

A common work flow is to check if a file is in the cache, if it is not to create it and write to cache, if the file is in cache you read it:

import cacheasy
x_cache_filepath = 'my_cool_x'
if cacheasy.file_in_cache(x_cache_filepath):
    x = cacheasy.read_from_cache(x_cache_filepath)
else:
    x = 5
    cacheasy.write_to_cache(x_cache_filepath)

Removing from cache

To delete a file from the cache:

import cacheasy
cacheasy.remove_from_cache('my_cool_x')

To easily delete all cache (including the folder):

import cacheasy
cacheasy.clear_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

cacheasy-0.0.6.tar.gz (3.5 kB view hashes)

Uploaded Source

Built Distribution

cacheasy-0.0.6-py3-none-any.whl (3.2 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