Cache store interface for different cache backends. Implementations: FileSystemCacheStore, MemoryCacheStore

Methods

cacheKey(key:String):String

Generate cache key (typically hashed)

expireCache():Void

Clean up expired cache entries

flush():Void

Flush all cache entries

forever<T>(key:String, data:T):Void

Store data forever (no expiration)

forget(key:String):Bool

Remove a key from cache

Returns:

true if removed successfully

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

has(key:String):Bool

Check if key exists in cache

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