You can provide an optional Map | Map, that will be used for storing the data.
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.
true if the entry was created, false if the key already existed
Retrieves a value by key without removing it.
Cache key to retrieve
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.).
Readable execution context for the operation
Cache key to retrieve and remove
The cached value, or null if not found or expired
Increments a numeric cache entry by a given amount. Useful for counters, rates, and statistics.
Cache key to increment
Amount to increment by.
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.
Readable execution context for the operation
Cache key to set
Value to cache
Time-to-live duration for this entry. Pass null to cache without expiration.
true if the entry was added, false if it was updated
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
Removes multiple cache entries at once.
Array of cache keys to remove
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
true if the entry was updated, false if the key did not exist
The
MemoryCacheAdapteris used for easily fakingICachefor testing.IMPORT_PATH:
"@daiso-tech/core/cache/memory-cache-adapter"