ttlru
Stores key/value pairs in a ttlru in-memory cache. This cache is therefore reset every time the service restarts.
-
Common
-
Advanced
# Common config fields, showing default values
label: ""
ttlru:
cap: 1024
default_ttl: 5m0s
init_values: {}
yml
# All config fields, showing default values
label: ""
ttlru:
cap: 1024
default_ttl: 5m0s
ttl: "" # No default (optional)
init_values: {}
optimistic: false
yml
The cache ttlru provides a simple, goroutine safe, cache with a fixed number of entries. Each entry has a per-cache defined TTL.
This TTL is reset on both modification and access of the value. As a result, if the cache is full, and no items have expired, when adding a new item, the item with the soonest expiration will be evicted.
It uses the package expirable
The field init_values can be used to pre-populate the memory cache with any number of key/value pairs:
cache_resources:
- label: foocache
ttlru:
default_ttl: '5m'
cap: 1024
init_values:
foo: bar
yaml
These values can be overridden during execution.
Fields
default_ttl
The cache ttl of each element
Type: string
Default: "5m0s"
Requires version 4.21.0 or newer
Was this helpful?