Key Value Database/Cache with abstract storage and plugins
Project description
zcache is pure python implementation of key value Cache/Database with abstract storage and plugins support.
Installation
pip install zcache
example
basic example:
from zcache import Cache
import time
c = Cache(path="/tmp/tes1.cache")
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.cache", 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
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.
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
zcache-1.0.10.tar.gz
(16.4 kB
view details)
Built Distribution
zcache-1.0.10-py3-none-any.whl
(15.1 kB
view details)
File details
Details for the file zcache-1.0.10.tar.gz
.
File metadata
- Download URL: zcache-1.0.10.tar.gz
- Upload date:
- Size: 16.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.15
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 899c887f76e036b94b33358fe52ac172c730f279882582d6e4e4a3d6df982c62 |
|
MD5 | 089c0398ba11d1bf0417d500fc6be1ee |
|
BLAKE2b-256 | 88c2511b67cd28271327d9916ba2490c42ccaa2a13be69e108bbcb84f3294300 |
File details
Details for the file zcache-1.0.10-py3-none-any.whl
.
File metadata
- Download URL: zcache-1.0.10-py3-none-any.whl
- Upload date:
- Size: 15.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.15
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d40e056e61a42b97aac028f1281e0b2f4e55685ad16f1a31194a8b6e009d2c5b |
|
MD5 | 6c9058e873eb9a5dedca5d72d83ebb86 |
|
BLAKE2b-256 | f055bf06771c111f2e60c237bf1433e4ecdb643af13876df4d7722b50479e1a0 |