Creates a new cache entry, but only if the key does not already exist. Has no effect if the key already exists.
Cache key to add
Value to cache
Time-to-live duration for this entry. Pass null to cache without expiration.
Readable execution context for the operation
true if the entry was created, false if the key already existed
Retrieves a value by key without removing it.
Cache key to retrieve
Readable execution context for the operation
The cached value, or null if not found or expired
Retrieves a value by key and immediately removes it. Useful for one-time-use values (tokens, temporary states, etc.).
Cache key to retrieve and remove
Readable execution context for the operation
The cached value, or null if not found or expired
The getOrAdd method retrieves the value for the given key if it exists,
otherwise adds the valueToAdd to the cache and returns it.
The cache key to retrieve or add.
The value to store if the key is not found.
Optional time-to-live for the cached item. If null is passed, the item will not expire.
Readable execution context for the operation
The cached value if the key exists, or the newly added value.
Increments a numeric cache entry by a given amount. Useful for counters, rates, and statistics.
Cache key to increment
Amount to increment by.
Readable execution context for the operation
true if the entry was incremented, false if the key did not exist
Creates a new cache entry or updates an existing one (upsert). Also updates the TTL when overwriting an existing entry.
Cache key to set
Value to cache
Time-to-live duration for this entry. Pass null to cache without expiration.
Readable execution context for the operation
true if the entry was added, false if it was updated
Removes all cache entries. Use with caution as this completely clears the cache.
Readable execution context for the operation
Removes all cache entries whose keys start with a given prefix. Useful for invalidating groups of related cache entries.
Key prefix to match for removal
Readable execution context for the operation
Removes multiple cache entries at once.
Array of cache keys to remove
Readable execution context for the operation
true if at least one key was removed, false if none existed
Updates an existing cache entry without changing its TTL. Has no effect if the key does not exist.
Cache key to update
New value to cache
Readable execution context for the operation
true if the entry was updated, false if the key did not exist
Low-level adapter contract for cache storage operations. Defines CRUD operations for key-value pairs with expiration support. This contract abstracts away the underlying cache storage technology (Redis, Memcached, database, etc.).
IMPORT_PATH:
"@daiso-tech/core/cache/contracts"