Cache Module
The cache
module is used to cache attributes. The idea is that you can look
up information in a database, and then cache it. Repeated requests for the same
information will then have the cached values added to the request.
The module can cache a fixed set of attributes per key.
It can be listed in any recv
or send
section.
If you want to have different things cached for different
sections, you will need to define multiple instances of the module,
via cache <nameN> { … } .
|
Option | Description |
---|---|
|
if it found or created a cache entry. |
|
if it merged a cached entry. |
|
if it did nothing. |
|
on error. |
Configuration Settings
- driver
-
The current backend datastore used to store the cache entries are:
Driver | Description |
---|---|
|
An in memory, non persistent rbtree based datastore. Useful for caching data locally. |
|
An in memory, non persistent datastore which can use a hash table, rbtree or patricia trie store depending on the data type of the key. |
|
A non persistent "webscale" distributed datastore. Useful if the cached data need to be shared between a cluster of RADIUS servers. |
|
A persistent "webscale" clustered, sharded, data store. Extremely fast, and a good candidate for sharing data such as EAP session blobs, between a cluster of servers. |
Some drivers accept specific options, to set them a config section with the the name as the driver should be added to the cache instance. |
Driver specific options are:
Htrie cache driver
- type
-
Htrie backend type
Option | Description |
---|---|
|
The backend is automatically determined based on data type of the key |
|
Use a hash table |
|
Use an rbtree |
|
Use a patricia trie # Memcached cache driver options:: Memcached configuration options. The memcached options are documented at http://docs.libmemcached.org/libmemcached_configuration.html#memcached pool:: Connection pool. # Redis cache driver server:: Redis Server name. If using Redis cluster, multiple 'bootstrap' servers may be listed here (as separate config items). These will be contacted in turn until one provides us with a valid map for the cluster. Server strings may contain unique ports. e.g.: server = '127.0.0.1:30001' server = '[::1]:30002' Instantiation failure behaviour is controlled by port:: Port to use for Redis server. The default port is 6379. password:: For authenticating ourselves to the Redis server. database:: The database number to use. pool:: Connection pool. key:: The ttl:: The TTL of cache entries, in seconds. Entries older than this will be expired. This value should be between NOTE: You can flush the cache via
add_stats:: If NOTE: Not supported by the max_entries:: Maximum entries allowed. update { … }:: The attributes to cache for a particular key. Each key gets the same set of cached attributes. The operation of the The solution (albeit an imperfect one) is that the cache
does not store attributes, it stores When the cache entry is created, the right-hand side of each attribute assignment line is expanded. The left-hand side of the attribute assignment is left alone. Once all of the right-hand side values are expanded, the
result is an When the cache entry is read, it is looked up by the For example, if the update { reply.Reply-Message := "Hello %{User-Name}" } When the cache entry is created, the module will expand the
right side of the entry, using the attributes from the
packet. In this case, the string could expand to Once all of the right-hand values are expanded, the resulting cache entry will look like this: update { reply.Reply-Message := "Hello bob" } When the cache module is read, this NOTE: Only <list>.<attribute> <op> <value>:: Cache all instances of Add our own to show when the cache was last updated. Add your own value for How to use # Configuration This module supports a number of runtime configuration parameters
represented by attributes in the control.Cache-TTL:: Sets the TTL of an entry to be created, or modifies the TTL of an existing entry. [options="header,autowidth"] |
| Condition | Description
| Cache-TTL
of > 0
| Set the TTL of the entry to the new value
(and reset the expiry timer).
| Cache-TTL
of < 0
| Expire the existing entry and create a new
one with TTL set to Cache-TTL
* -1
.
| Cache-TTL
of 0
| Expire the existing entry and create a new one.
control.Cache-Status-Only:: If present and set to * The module will return NOTE: If this is set to control.Cache-Allow-Insert:: If present and set to control.Cache-Allow-Merge:: If present and set to control.Cache-Merge-New:: If present and set to NOTE: All runtime configuration attributes will be removed from the
# Methods The cache module also allows handling the cache using the methods. cache.status:: Verify if an entry already exists without load the entries. [options="header,autowidth"] |
| Return | Description
| ok
| if a cache entry was found.
| notfound
| if no cache entry was found.
| fail
| if the cache was unavailable.
cache.load:: Load an existing cache entry and merge it into the request. [options="header,autowidth"] |
| Return | Description
| updated
| if a cache entry was found and loaded.
| notfound
| if no cache entry was found.
| fail
| if the cache was unavailable.
cache.update:: Perform an upsert against the data store, updating the entry TTL [options="header,autowidth"] |
| Return | Description
| updated
| if we added cache entry.
| fail
| if the cache was unavailable.
cache.store:: Inserts data into the cache if, and only if, it is not already present Will not update the entry TTL. [options="header,autowidth"] |
| Return | Description
| updated
| we created or updated a cache entry.
| noop
| if a cache entry aready existed.
| fail
| if the cache was unavailable.
cache.clear:: Delete cache entry from the data store without checking if the entry already exists. [options="header,autowidth"] |
| Return | Description
| ok
| if we found and removed a entry.
| notfound
| if no cache entry was found.
| fail
| if the cache was unavailable.
cache.ttl:: Change the TTL on an existing entry. [options="header,autowidth"] |
| Return | Description
| updated
| if we found entry and updated the ttl.
| notfound
| if no cache entry was found.
| fail
| if the cache was unavailable.
# Examples
[NOTE]
====
* This is evaluated before == Default Configuration
|