Fluent builder for declaring an app-scoped, in-memory cache, reached from controllerMappings.cacheBuilder(). Set the cache name and optionally its maximum size and expiry, then call build to register it. Once registered, values are read and populated through getCacheValue on the controller mappings, using a key that is automatically scoped per organisation and, for a website, per branch. Caches are process-local and not shared between server instances.
Group: Builders
Methods
cacheName(String cacheName)
Returns: CacheBuilder
Sets the name of the cache, unique within the app. Required before calling build.
| Parameter | Description |
|---|---|
cacheName | the cache name |
maxSize(long maxSize)
Returns: CacheBuilder
Sets the maximum number of entries the cache holds before evicting older entries. Defaults to 100 if not set.
| Parameter | Description |
|---|---|
maxSize | the maximum number of cache entries, up to 1000 |
expireAfterAccess(long expireAfterAccess)
Returns: CacheBuilder
Sets how long, in seconds, an entry is kept after it was last read before it expires. If neither this nor expireAfterWrite is set, entries expire one hour after last access.
| Parameter | Description |
|---|---|
expireAfterAccess | seconds since last access before an entry expires, up to 21600 (6 hours) |
expireAfterWrite(Long expireAfterWrite)
Returns: CacheBuilder
Sets how long, in seconds, an entry is kept after it was written before it expires.
| Parameter | Description |
|---|---|
expireAfterWrite | seconds since last write before an entry expires, up to 86400 (24 hours) |
build()
Returns: void
Registers the cache under the configured name so it can be read and populated through getCacheValue. Requires cacheName to have been set. Has no effect on the live cache once the app's engine has already finished initialising, though the configuration is still recorded so the cache can be rebuilt if evicted.