All Projects → atmb4u → Cashier

atmb4u / Cashier

Licence: bsd-2-clause
Persistent caching for python functions

Programming Languages

python
139335 projects - #7 most used programming language
python3
1442 projects
python2
120 projects

Projects that are alternatives of or similar to Cashier

Twig Cache Extension
Stars: ✭ 67 (-16.25%)
Mutual labels:  cache
Cachemanage
🔥android缓存管理器,分为内存缓存和文件缓存两种 先取内存数据,没有再从文件缓存中取
Stars: ✭ 73 (-8.75%)
Mutual labels:  cache
Gitcache
When clone from github.com, build mirror cache to improve clone speed
Stars: ✭ 77 (-3.75%)
Mutual labels:  cache
Cashew
A simple and elegant yet powerful HTTP client cache for .NET
Stars: ✭ 70 (-12.5%)
Mutual labels:  cache
Proteus
Proteus : A JSON based LayoutInflater for Android
Stars: ✭ 1,179 (+1373.75%)
Mutual labels:  functions
Keshi
A better in-memory cache for Node and the browser
Stars: ✭ 75 (-6.25%)
Mutual labels:  cache
Apollo Cache Invalidation
Experimental cache invalidation tools for Apollo.
Stars: ✭ 66 (-17.5%)
Mutual labels:  cache
Awesomecache
Delightful on-disk cache (written in Swift)
Stars: ✭ 1,223 (+1428.75%)
Mutual labels:  cache
Terraform Aws Elasticache Redis
Terraform module to provision an ElastiCache Redis Cluster
Stars: ✭ 73 (-8.75%)
Mutual labels:  cache
Comet Cache
An advanced WordPress® caching plugin inspired by simplicity.
Stars: ✭ 78 (-2.5%)
Mutual labels:  cache
Zio Tls Http
100% non-blocking, Java NIO only( inspired by zio-nio) , JSON HTTP server based on Scala ZIO library. Everything including TLS encryption modeled as ZIO effects, convenient route DSL similar to https4s, up to 30K TPS local JSON transaction with 25 threads on 6 cores(i7) with ZIO fibers.
Stars: ✭ 71 (-11.25%)
Mutual labels:  cache
Postgresql Provider
PostgreSQL Provider for the Vapor web framework.
Stars: ✭ 71 (-11.25%)
Mutual labels:  cache
Cloud Functions Typescript Template
TypeScript template for Google Cloud Functions
Stars: ✭ 75 (-6.25%)
Mutual labels:  functions
Android Filelogger
A general-purpose logging library with built-in support to save logs to file efficiently.
Stars: ✭ 70 (-12.5%)
Mutual labels:  persistent
Memorystore
express-session full featured MemoryStore layer without leaks!
Stars: ✭ 79 (-1.25%)
Mutual labels:  cache
Kong Plugin Response Cache
A Kong plugin that will cache responses in redis
Stars: ✭ 66 (-17.5%)
Mutual labels:  cache
Openwhisk Cli
Apache OpenWhisk Command Line Interface (CLI)
Stars: ✭ 73 (-8.75%)
Mutual labels:  functions
Tache
A tag based invalidation caching library
Stars: ✭ 80 (+0%)
Mutual labels:  cache
Minicache
📦 Python memory caching utilities
Stars: ✭ 79 (-1.25%)
Mutual labels:  cache
Realpath cache tuner
Simple script that helps tuning PHP realpath cache
Stars: ✭ 78 (-2.5%)
Mutual labels:  cache

Cashier

Persistent caching for python functions

Simply add a decorator to a python function and cache the results for future use. Extremely handy when you are dealing with I/O heavy operations which seldom changes or CPU intensive functions as well.

Anatomically, once a function is called, result from the function is cached into an SQLite3 database locally, with an expiry time. There is a maximum length for the cache to prevent cache flooding the file system.

Installation

pip install cashier

Or you can clone the source and run setup.py

git clone [email protected]:atmb4u/cashier.git
cd cashier
python setup.py install

Usage

from cashier import cache

@cache()
def complex_function(a,b,c,d):
    return complex_calculation(a,b,c,d)

If you go ahead on the above configuration, following are the default values

  • cache_file : .cache

  • cache_time : 84600

  • cache_length : 10000

  • retry_if_blank : False

Advanced Usage

from cashier import cache

@cache(cache_file="sample.db", cache_time=7200, cache_length=1000, 
       retry_if_blank=True)
def complex_function(a, b, c, d):
    return complex_calculation(a, b, c, d)

cache_file : SQLite3 file name to which cached data should be written into (defaults to .cache)

cache_time : how long should the data be cached in seconds (defaults to 1 day)

cache_length : how many different arguments and corresponding data should be cached (defaults to 10000)

retry_if_blank : If True, will retry for the data if blank data is cached ( default is False)

Performance Benchmark

For reproducing results, run python test.py from the project root.

No Cache Run: 9.932126 seconds

First Caching Run: 9.484081 seconds

Cached Run: 0.606016 seconds (16 x faster)

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].