CacheConfig
Configuration for a CachePolicy.
This class is used to configure the behavior of a cache policy, such as setting a unique key for a cache entry, its time-to-live (TTL), and periodic cleanup parameters.
Cache key: Use key for a fixed key, or keyProvider for a key derived at execution time (e.g. from request context, user id, or arguments captured in the lambda). If keyProvider is set, it is invoked on each CachePolicy.execute and its result is used as the cache key; otherwise key is used. This allows reusing the same cache policy for multiple logical resources (e.g. keyProvider = { "user:${userId}" }).
Properties
The maximum number of expired entries to remove in a single cleanup run. This helps to avoid long-running cleanup tasks. Defaults to 100.
The interval at which expired cache entries are automatically removed. If null, automatic cleanup is disabled. Defaults to null. This requires a ResilientScope to be provided to the cache policy.
The unique identifier for a cache entry when keyProvider is null. Defaults to "default".
Optional suspend lambda that returns the cache key at execution time. If set, takes precedence over key. Use for dynamic keys (e.g. per-request, per-tenant).