Skip to main content

INSTALLATION

>>> pip install dummycache

USAGE

>>> from dummycache import Cache
>>> c = Cache()

The basic interface is set(key, value, timeout=None) and get(key, default=None):

>>> c.set('key_a', 'Good morning, today!', 60)    # Set value in cache for 60 seconds
>>> c.get('key_a')
'Good morning, today!'

Wait 60 seconds:

>>> c.get('key_a')
None

If timeout is not provided, the value is saved forever or until it is overridden or explicitly deleted:

>>> c.set('key_b', 'Good afternoon, forever!')    # Set value in cache forever

If timeout is zero or negative, the value is not saved. The value previously saved with the same key will also be deleted:

>>> c.set('key_b', 'Good bye', 0)    # The value is not set
>>> c.get('key_b')
None

cache.get() can take a default argument. This specifies which value to return if the object doesn’t exist in the cache:

>>> c.get('key_a', 'has expired')
'has expired'

To add a key only if it doesn’t already exist, use the add() method. It takes the same parameters as set(), but it will not attempt to update the cache if the key specified is already present:

>>> c.set('key_c', 'Initial value')
>>> c.add('key_c', 'New value')
>>> c.get('key_c')
'Initial value'

If you need to know whether add() stored a value in the cache, you can check the return value. It will return True if the value was stored, False otherwise.

You can delete keys explicitly with delete(). This is an easy way of clearing the cache for a particular object:

>>> c.delete('key_c')
Finally, if you want to delete all the keys in the cache, use clear(). Be careful with this; clear() will remove

everything from the cache, not just the keys set by your application.

>>> c.clear()

Metadata

Release files for dummycache 0.0.2

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

Source distribution (sdist)

Source distribution for dummycache 0.0.2
File Size Uploaded Provenance Actions
dummycache-0.0.2.tar.gz 3.8 kB Without provenance Details for dummycache-0.0.2.tar.gz

Release files / dummycache-0.0.2.tar.gz

Download URL dummycache-0.0.2.tar.gz
Size 3.8 kB
Tags Source
SHA-256 checksum
How to use checksums
7351c19fc84c16154ca7b0dcdc479c9d22b7893685287aa4993f6cc1878a2207
BLAKE2b-256 checksum
How to use checksums
e21b5420ba197f15d139520901bb03ef8be3be7030ea2fdd1990f229a2991e0b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for dummycache 0.0.2

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

0.0.2 This release

1 release file 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