https://github.com/etienne-napoleone/poche
🎒 Simple and fast Python in-memory caching library
https://github.com/etienne-napoleone/poche
cache fast in-memory library python simple
Last synced: over 1 year ago
JSON representation
🎒 Simple and fast Python in-memory caching library
- Host: GitHub
- URL: https://github.com/etienne-napoleone/poche
- Owner: etienne-napoleone
- License: gpl-3.0
- Created: 2019-12-31T03:21:14.000Z (over 6 years ago)
- Default Branch: main
- Last Pushed: 2021-02-18T11:11:05.000Z (over 5 years ago)
- Last Synced: 2024-11-12T09:26:27.882Z (over 1 year ago)
- Topics: cache, fast, in-memory, library, python, simple
- Language: Python
- Homepage:
- Size: 188 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# poche
[](https://travis-ci.org/etienne-napoleone/poche)
[](https://codecov.io/gh/etienne-napoleone/poche)
[](http://mypy-lang.org/)
[](https://github.com/psf/black)
Simple and fast Python in-memory caching with support for TTLs.
Meant to speed up using dictionaries as cache backend for simple usecases.
No external dependencies, 100% code coverage and static type checked.
## Installation
Requires Python 3.6+.
```bash
pip install poche
```
## Roadmap
v1:
- [x] Basic TTL
- [x] `get`
- [x] `set`
- [x] `getset`
- [x] `flush`
v1.1:
- [ ] `expire`
- [ ] `persist`
- [ ] `rename`
v1.2:
- [ ] `getorset` with callback
## Example
```python
from time import sleep
import poche
>>> c = poche.Cache()
>>> c.set("one", "uno")
>>> c.get("one")
"uno"
>>> c.get("two")
None
>>> c.getset("two", "dos")
None
>>> c.get("two")
"dos"
>>> c.set("three", "tres", ttl=2)
>>> c.get("three")
"tres"
>>> sleep(2)
>>> c.get("three")
None
>>> c = poche.Cache(ttl=2) # you can also define a default TTL
>>> c.set("four", "cuatro")
>>> c.get("four")
"cuatro"
>>> sleep(2)
>>> c.get("four")
None
```