Skip to main content

cachepot

PyPI - Python Version PyPI PyPI - Downloads Lint and Test Python codecov License

Yet another Python cache library. This has Python 3 typing hints.

Installation

$ pip install cachepot

Usage

>>> from cachepot.store import CacheStore
>>> from cachepot.backend.filesystem import FileSystemCacheBackend
>>> from cachepot.serializer.pickle import PickleSerializer
>>> store = CacheStore(
...     namespace='testing',
...     key_serializer=PickleSerializer(),
...     value_serializer=PickleSerializer(),
...     backend=FileSystemCacheBackend('/tmp'),
...     default_expire_seconds=3600,
... )
>>> store.put({'some': 'key'}, {'some': 'value'})
>>> store.get({'some': 'key'})
{'some': 'value'}
>>> store.put({'some': 'short expiring key'}, {'some': 'value'}, expire_seconds=10)

Proxy method

result = store.proxy(some_func)(some_args)

is the equivalent of

result = store.get(some_arg)
if result is None:
    result = some_func(some_args)
    store.set(result)

In short, this works as proxy. This helps to make codes straight forward. proxy method can be passed two arguments cache_key and expire_seconds.

Core idea

Serializers convert python objects into bytes. Backends save/load bytes. So serializers and backends are independent. CacheStore is the facade of them.

  • Python3 typing supports
  • namespaces
  • Proxy method

Features

Serializers

And more serializers you can define.

Backends

Of course you can define own backend.

Development

You can install requirements with poetry.

$ poetry install

Test

$ poetry poe check  # lint and type check
$ poetry poe test  # run tests

LICENSE

The 3-Clause BSD License. See also LICENSE file.

Download files

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

Source Distribution

cachepot-0.4.0.tar.gz (33.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cachepot-0.4.0-py3-none-any.whl (13.5 kB view details)

Uploaded Python 3

File details

Details for the file cachepot-0.4.0.tar.gz.

File metadata

  • Download URL: cachepot-0.4.0.tar.gz
  • Upload date:
  • Size: 33.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for cachepot-0.4.0.tar.gz
Algorithm Hash digest
SHA256 690f1f028dd28b1d9fff3dc2c2c7774e1ba2875992014bd9fe41a8613580a124
MD5 afde69ed619e6a4ab9278b8fcbcb9dfa
BLAKE2b-256 fa88db63d9780847639cd52c067ace4823d36466b508b93bb5447b5b47e2cf7a

See more details on using hashes here.

File details

Details for the file cachepot-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: cachepot-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 13.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for cachepot-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8d0ed4951dad9e50383f4332821b9b58f6f5a5b8fb7338f86549c5ec02c15fb9
MD5 4a2d015d9dd658773ace39203e6f2a24
BLAKE2b-256 2a890e7fb87cc7ce3b87548fa7617fd8f9e20636d2bcea5b08e9f5d1dc7d85a5

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.4.0 This release

2 files

0.3.0

2 files

0.2.0

2 files

0.1.6

2 files

0.1.5

2 files

0.1.4

2 files

0.1.3

2 files

0.1.2

2 files

0.1.1

2 files

0.1.0

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page