https://github.com/im-cloud-spain-connectors/python-cache-sqlite-adapter
SQLite implementation of the Cache Interface for Python.
https://github.com/im-cloud-spain-connectors/python-cache-sqlite-adapter
adapter cache component python sqlite
Last synced: 8 months ago
JSON representation
SQLite implementation of the Cache Interface for Python.
- Host: GitHub
- URL: https://github.com/im-cloud-spain-connectors/python-cache-sqlite-adapter
- Owner: IM-Cloud-Spain-Connectors
- License: apache-2.0
- Created: 2023-01-10T14:58:21.000Z (about 3 years ago)
- Default Branch: master
- Last Pushed: 2023-10-31T20:43:30.000Z (over 2 years ago)
- Last Synced: 2025-02-25T21:44:26.394Z (11 months ago)
- Topics: adapter, cache, component, python, sqlite
- Language: Python
- Homepage:
- Size: 37.1 KB
- Stars: 2
- Watchers: 4
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Python Cache SQLite Adapter
[](https://github.com/othercodes/python-cache-sqlite-adapter/actions/workflows/test.yml)
Provides a SQLite implementation of the Cache Interface for Python.
## Installation
The easiest way to install the Cache SQLite Adapter is to get the latest version from PyPI:
```bash
# using poetry
poetry add rndi-cache-sqlite-adapter
# using pip
pip install rndi-cache-sqlite-adapter
```
## The Contract
The used interface is `rndi.cache.contracts.Cache`.
## The Adapter
Just initialize the class you want and use the public methods:
```python
from rndi.cache.contracts import Cache
from rndi.cache.adapters.sqlite.adapter import SQLiteCacheAdapter
def some_process_that_requires_cache(cache: Cache):
# retrieve the data from cache, ir the key is not cached yet and the default
# value is a callable the cache will use it to compute and cache the value
user = cache.get('user-id', lambda: db_get_user('user-id'))
print(user)
# inject the desired cache adapter.
cache = SQLiteCacheAdapter('/tmp', 900)
some_process_that_requires_cache(cache)
```