Skip to main content

Cacheia

Cacheia has all the core functionality for the "cacheia" package. It exposes a simple interface for multiple cache providers with added features like cache invalidation and cache expiration.

Installation

Install core with "schemas" optional to download schemas dependency:

pip install -e ./core[schemas]

Code

Cacheia mainly exposes one interface to interact with all backends and some custom exceptions:

  • Cacheia: The main interface to interact with all backends.
  • InvalidSettings: Exception raised when an invalid settings class type is passed to Cacheia.setup method.
  • KeyAlreadyExists: Exception raised when a key already exists in the cache and the user tries to set it again.
  • decorator: Module that exposes a decorator to cache function calls.

Examples

To create a new cache:

from cacheia import Cacheia
from cacheia_schemas import CachedValue


Cacheia.setup()
cache = Cacheia.get()
instance = CachedValue(key="key", value="value")
cache.cache(instance=instance)

To get all cached values:

from cacheia import Cacheia


Cacheia.setup()
cache = Cacheia.get()
for value in cache.get():
    print(value)

To get a value from the cache:

from cacheia import Cacheia


Cacheia.setup()
cache = Cacheia.get()
cached_value = cache.get_key("key")
print(cached_value)

To flush all values:

from cacheia import Cacheia


Cacheia.setup()
cache = Cacheia.get()
result = cache.flush()
print(result.deleted_count)

To flush some values:

from datetime import datetime
from cacheia import Cacheia


Cacheia.setup()
cache = Cacheia.get()

now = datetime.now().timestamp()
result = cache.flush(expires_range=(now - 100, now + 100))
print(result.deleted_count)

To flush a single key:

from cacheia import Cacheia


Cacheia.setup()
cache = Cacheia.get()

result = cache.flush_key(key="key")
print(result.deleted_count)

Metadata

Release files for cacheia 1.0.0.post3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cacheia 1.0.0.post3
File Size Uploaded Provenance Actions
cacheia-1.0.0.post3.tar.gz 7.2 kB Without provenance Details for cacheia-1.0.0.post3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for cacheia 1.0.0.post3
File Interpreter ABI Platform Actions
cacheia-1.0.0.post3-py3-none-any.whl Python 3 none any Details for cacheia-1.0.0.post3-py3-none-any.whl

Total release size: 13.7 kB

Release files / cacheia-1.0.0.post3.tar.gz

Download URL cacheia-1.0.0.post3.tar.gz
Size 7.2 kB
Tags Source
SHA-256 checksum
How to use checksums
89d39006bd0c34200040841c64522f992456417c6e5ef4a81b555fa78e81965a
BLAKE2b-256 checksum
How to use checksums
519f5b5fffd2f5fcc9f982088ce0f8ca3ee7a63ae45e9ae6dbec06068aa9f6a7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.4

Release files / cacheia-1.0.0.post3-py3-none-any.whl

Download URL cacheia-1.0.0.post3-py3-none-any.whl
Size 6.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a62c785ef1f141cc601b45f700886c027b413c099c90c5123ff738013ece0f13
BLAKE2b-256 checksum
How to use checksums
b441533660481096881fa94d9ecb646a4aa1d7916052431cadfd5ce375394b3a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.4

Security for cacheia 1.0.0.post3

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.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.0.post3 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page