Skip to content

takelushi/kioku

Repository files navigation

kioku

Simple Cache Library for Python.

Usage

Quick Start

import time

from kioku import Cache

cache = Cache('./cache.pkl')

@cache.use()
def calc():
   time.sleep(3)
   return 42

# It takes 3 sec...
print(calc())
# => 42

# Without to run calc() by using cache.
print(calc())
# => 42

# Cache is saved as dict.
# And key is function name.
print(cache.get('calc'))
# => 42

Basic

# Set manually
cache.set('key', 123)
print(cache.get('key'))
# => 123

# Clear
cache.clear('key')
print(cache.get('key'))
# => None

Auto Reloading Cache File

cache = Cache('cache.pkl', auto_reload=True)

Development

  • Requirements: poetry, pyenv
# Setup
poetry install

# Lint & Test
mkdir -p report
poetry run flake8 --format=html --htmldir=report/flake-report .
mypy src/ tests/ --html-report report/mypy
poetry run pytest \
   --html=report/pytest/index.html\
   --cov-report html:report/coverage

# Build and publish
poetry build
poetry publish

About

Simple Python Cache Library.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages