Skip to main content

Pure typed Python Key Value Database/Cache with abstract storage, plugins and asynchronous support

Project description

ruff status workflow test status workflow build

Downloads Downloads Downloads

zcache is pure typed Python implementation of key value Cache/Database with abstract storage and plugins.

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

Version Limited

version ^2.0.2 is limited without Asynchronous and no need any dependency.

License

MIT

Project details


Download files

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

Source Distribution

zcache-2.0.4.tar.gz (19.8 kB view details)

Uploaded Source

Built Distribution

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

zcache-2.0.4-py3-none-any.whl (18.5 kB view details)

Uploaded Python 3

File details

Details for the file zcache-2.0.4.tar.gz.

File metadata

  • Download URL: zcache-2.0.4.tar.gz
  • Upload date:
  • Size: 19.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.10.15

File hashes

Hashes for zcache-2.0.4.tar.gz
Algorithm Hash digest
SHA256 121634e4eb67132caaf132be7024b8836713318583e07612e37b1050677d4f42
MD5 0d1cd041e3d223ae9562df1db9c3deec
BLAKE2b-256 038e5467e7cc60b5855cbafbb772064855627630c9204813d322d69ac04c8f88

See more details on using hashes here.

File details

Details for the file zcache-2.0.4-py3-none-any.whl.

File metadata

  • Download URL: zcache-2.0.4-py3-none-any.whl
  • Upload date:
  • Size: 18.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.10.15

File hashes

Hashes for zcache-2.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 61f8daf3ba3d817f776bf5717f429631f26159f17e804cad6f8a8df589f1c678
MD5 d5bc92b9a0c617c069aed9ff89b0520d
BLAKE2b-256 942e5d85596e29a6f4a3616061c9e2427f5a9f16e518946238f8c80ec33f4f63

See more details on using hashes here.

Supported by

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