zcache is pure typed Python implementation of key value Cache/Database with abstract storage, plugins and asynchronous support.
Installation
pip install zcache
example
basic example:
from zcache import Cache
import time
c = Cache(path="/tmp/tes1.json")
print("set foo=bar: ", c.set("foo", "bar"))
print("c size:", c.size())
print("c has foo: ", c.has("foo"))
print("c get foo: ", c.get("foo"))
print("c delete foo: ", c.delete("foo"))
print("c has foo: ", c.has("foo"))
print("c has spam:", c.has("spam"))
print("c set spam=eggs, ttl=3: ", c.set("spam", "eggs", ttl=3)) # cache with ttl
print("c has spam:", c.has("spam"))
print("sleep 3")
time.sleep(3)
print("c has spam:", c.has("spam"))
print("c size:", c.size())
example with limited stack:
from zcache import Cache
d = Cache(path="/tmp/test2.json", limit=2)
d.reset() # reset cache stack to 0
print(d.set("one", 1)) # True
print(d.set("two", 2)) # True
print(d.set("three", 3)) # False out of stack limit
d.delete("one") # delete one item from stack
print(d.set("three", 3)) # True
Asynchronous
example asynchronous usage
import asyncio
from zcache import AsyncCache
async def main():
c = AsyncCache()
await c.init()
await c.set("test", "OK")
print(await c.get("test"))
if __name__ == '__main__':
asyncio.run(main())
Storage and plugins
you can change storage and use plugins, for example:
from zcache import Cache
from zcache.Plugins.BytesCachePlugins import BytesCachePlugins
from zcache.Storage.BaseFileStorage import BaseFileStorage
storage = BaseFileStorage("/tmp/zcache.json")
plugins = BytesCachePlugins()
c = Cache(storage=storage, plugins=plugins)
see list current available storage and plugins, you can also create your own storage and plugins.
Extras
Extras is several module based on zcache.
SmartRequest is Simple HTTP Client with smart caching system based on zcache.
AsyncSmartRequest is asynchronous version of SmartRequests.
Queue is Fifo Queue based on zcache.
AsyncQueue is asynchronous version of Queue.
License
MIT
Metadata
Release files for zcache 3.0.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| zcache-3.0.5.tar.gz | 12.0 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| zcache-3.0.5-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 40.2 kB
Release files / zcache-3.0.5.tar.gz
| Download URL | zcache-3.0.5.tar.gz |
|---|---|
| Size | 12.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d0222535c98d35ed1f41c439cdd5835b5bbab03ec520744f9bbac00598f3c19a
|
|
BLAKE2b-256 checksum How to use checksums |
bf84b2461f511e8308d5cdcfc896da19c8a96b3972b1333dcaaf8518070fe45a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.9.20
|
Release files / zcache-3.0.5-py3-none-any.whl
| Download URL | zcache-3.0.5-py3-none-any.whl |
|---|---|
| Size | 28.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
696666fc2f2f683fe073a63202fc3f59bb5bf363a0a7c7e82a64de90fd38a7af
|
|
BLAKE2b-256 checksum How to use checksums |
0bc5e7f328ffa4d0416b1633026eff27f97aed2b31c3dc481ed20d4a2b07615d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.9.20
|
Security for zcache 3.0.5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.