caches service
Adds lru-cache-based caching to Flobot. Note defaults will be used if no caches
configuration is provided. This service is provided via the
flobot plugin and isn't offered by any of the other core plugins.
Boot config
{
"caches": {
"userMemberships": {
"max": 500
}
}
}
Property | Type | Description | Required |
---|---|---|---|
max | number |
The maximum size of the cache, checked by applying the length function to all values in the cache. Not setting this will fall-back to a service-level default. | No |
maxAge | number |
Maximum age in ms. Items are not pro-actively pruned out as they age, but if you try to get an item that is too old, it’ll drop it and return undefined | No |
Service methods/properties
defaultIfNotInConfig
Any cache defined in the config will be automatically created at boot-time… the defaultIfNotInConfig
method allows services to explicitly define a required cache if not mentioned in config.
Parameters
cacheName
string Unique name of the cache to create if not in configoptions
Object As per the config section
Examples
caches.defaultIfNotInConfig(
'userMemberships',
{
max: 500
}
)
Returns undefined