Skip to main content

Cacheia CLient

This module contains a client that is responsible for communicating with the Cacheia API. It is a simple wrapper around the API endpoints, providing a more user-friendly interface for the user.

Installation

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

pip install -e ./client[schemas]

Client Methods

  • cache: Takes instance (CreateRequest), creator (Infostar) and backend to create a new cache instance in the provided backend.
  • get: Retrieves all cached values with optional filters group (str), expires_range (tuple[float, float]) and creation_range(tuple[datetime, datetime]);
  • get_key: Fetches the cached value associated with key (str) - Optionally accepts allow_expired parameter to return a cached value even if expired.
  • flush: Clears all keys from the cache using with optional filters group (str), expires_range (tuple[float, float]) and creation_range(tuple[datetime, datetime]) and return the count of deleted records.
  • flush_key: Removes a single key from the cache using key (str).
  • clear: Removes all cached values from cache without any validation.

Code

The library exposes single functions that are similar to requests and httpx and also exposes a Client class that can be used to define default value for API URL.

Examples

To create a cache instance with the client:

from cacheia_client import Client
from cacheia_schemas import CachedValue


default_url: str = "http://localhost:5000"

client = Client(url=default_url)
instance = CachedValue(key="key", value="value")

client.cache(instance=instance)

Or using the helper functions:

from cacheia_client import cache, configure
from cacheia_schemas import CachedValue


configure("http://localhost:5000")

instance = CachedValue(key="key", value="value")
cache(instance=instance)

Notice that when calling directly the functions, it is necessary to call "configure" with the desired URL. Otherwise, it will fail.


To get all cached values:

from cacheia_client import Client


default_url: str = "http://localhost:5000"
client = Client(url=default_url)

for v in client.get_all():
    print(v)

To get a single cached value:

from cacheia_client import Client


default_url: str = "http://localhost:5000"
client = Client(url=default_url)
print(client.get(key="key"))

To flush all keys:

from cacheia_client import Client


default_url: str = "http://localhost:5000"
client = Client(url=default_url)

result = client.flush()
print(result.deleted_count)

To flush some keys:

from datetime import datetime
from cacheia_client import Client


default_url: str = "http://localhost:5000"
client = Client(url=default_url)

now = datetime.now().timestamp()
result = client.flush(expires_range=(now-10, now+10))
print(result.deleted_count)

To flush a single key:

from cacheia_client import Client


default_url: str = "http://localhost:5000"
client = Client(url=default_url)

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

Metadata

Release files for cacheia-client 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-client 1.0.0.post3
File Size Uploaded Provenance Actions
cacheia_client-1.0.0.post3.tar.gz 3.6 kB Without provenance Details for cacheia_client-1.0.0.post3.tar.gz

Built distribution (wheel)

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

Total release size: 7.7 kB

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

Download URL cacheia_client-1.0.0.post3.tar.gz
Size 3.6 kB
Tags Source
SHA-256 checksum
How to use checksums
1ca9ced65ff88e1e2ecda69c42e7ec3550c52c8891776413b5f916826b391081
BLAKE2b-256 checksum
How to use checksums
db12f2586a4fea1a0baf59e468996acf9ccd200197a7f23e85e5804095851f32
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.4

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

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

Security for cacheia-client 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