Cache store interface for different cache backends. Implementations: FileSystemCacheStore, MemoryCacheStore
Methods
get<T>(key:String, ?defaultValue:T):T
Get cached data
Parameters:
key | Cache key |
|---|---|
defaultValue | Value to return if key not found or expired |
Returns:
Cached data or defaultValue
getMany<T>(keys:Array<String>):Map<String, T>
Get multiple values at once
Parameters:
keys | Array of cache keys |
|---|
Returns:
Map of key -> value pairs
leftTime(key:String):Int
Get remaining TTL for a key
Returns:
Remaining seconds, 0 if expired or not found, -1 if forever
put<T>(key:String, data:T, seconds:Null<Int>):Void
Store data with TTL (time-to-live)
Parameters:
key | Cache key |
|---|---|
data | Data to store |
seconds | Time to live in seconds, null for forever |
putMany<T>(values:Map<String, T>, seconds:Null<Int>):Void
Store multiple values at once
Parameters:
values | Map of key -> value pairs |
|---|---|
seconds | Time to live in seconds |
touch(key:String, seconds:Null<Int>):Bool
Refresh a cache entry's TTL without rewriting data
Parameters:
key | Cache key |
|---|---|
seconds | New TTL in seconds, null for forever |
Returns:
true if the entry exists and was touched