All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Typedefs | Functions | Variables
rlm_cache_redis.c File Reference

redis based cache. More...

#include <freeradius-devel/radiusd.h>
#include <freeradius-devel/rad_assert.h>
#include "../../rlm_cache.h"
#include "../../../rlm_redis/redis.h"
#include "../../../rlm_redis/cluster.h"
+ Include dependency graph for rlm_cache_redis.c:

Go to the source code of this file.

Data Structures

struct  rlm_cache_redis
 

Typedefs

typedef struct rlm_cache_redis rlm_cache_redis_t
 

Functions

static cache_status_t cache_entry_expire (UNUSED rlm_cache_config_t const *config, void *driver_inst, REQUEST *request, UNUSED void *handle, uint8_t const *key, size_t key_len)
 Call delete the cache entry from redis. More...
 
static cache_status_t cache_entry_find (rlm_cache_entry_t **out, UNUSED rlm_cache_config_t const *config, void *driver_inst, REQUEST *request, UNUSED void *handle, uint8_t const *key, size_t key_len)
 Locate a cache entry in redis. More...
 
static void cache_entry_free (rlm_cache_entry_t *c)
 
static cache_status_t cache_entry_insert (UNUSED rlm_cache_config_t const *config, void *driver_inst, REQUEST *request, UNUSED void *handle, const rlm_cache_entry_t *c)
 Insert a new entry into the data store. More...
 
static int mod_instantiate (CONF_SECTION *conf, rlm_cache_config_t const *config, void *driver_inst)
 Create a new rlm_cache_redis instance. More...
 

Variables

static CONF_PARSER driver_config []
 
cache_driver_t rlm_cache_redis
 

Detailed Description

redis based cache.

Id:
fb0c94aea48ce8071bbb3775b4f66b4b2ee92ce6

Definition in file rlm_cache_redis.c.


Data Structure Documentation

struct rlm_cache_redis

Definition at line 36 of file rlm_cache_redis.c.

+ Collaboration diagram for rlm_cache_redis:
Data Fields
fr_redis_cluster_t * cluster
fr_redis_conf_t conf Connection parameters for the Redis server.

Must be first field in this struct.

vp_tmpl_t created_attr LHS of the Cache-Created map.
vp_tmpl_t expires_attr LHS of the Cache-Expires map.

Typedef Documentation

Function Documentation

static cache_status_t cache_entry_expire ( UNUSED rlm_cache_config_t const *  config,
void *  driver_inst,
REQUEST request,
UNUSED void *  handle,
uint8_t const *  key,
size_t  key_len 
)
static

Call delete the cache entry from redis.

Note
This callback is not optional.
Parameters
[in]configfor this instance of the rlm_cache module.
[in]driver_instDriver specific instance data.
[in]requestThe current request.
[in]handlethe driver gave us when we called cache_acquire_t, or NULL if no cache_acquire_t callback was provided.
[in]keyof entry to expire.
[in]key_lenthe length of the key string.
Returns

Definition at line 415 of file rlm_cache_redis.c.

+ Here is the call graph for this function:

static cache_status_t cache_entry_find ( rlm_cache_entry_t **  out,
UNUSED rlm_cache_config_t const *  config,
void *  driver_inst,
REQUEST request,
UNUSED void *  handle,
uint8_t const *  key,
size_t  key_len 
)
static

Locate a cache entry in redis.

If a cache entry is found, but the cache entry needs to be deserialized, the driver is expected to allocate an appropriately sized rlm_cache_entry_t, perform the deserialisation, and write a pointer to the new entry to out, returning CACHE_OK.

If the rlm_cache_handle_t is inviable, the driver should return CACHE_RECONNECT, to have it reinitialised/reconnected.

Parameters
[out]outWhere to write a pointer to the retrieved entry (if there was one).
[in]configfor this instance of the rlm_cache module.
[in]driver_instDriver specific instance data.
[in]requestThe current request.
[in]handlethe driver gave us when we called cache_acquire_t, or NULL if no cache_acquire_t callback was provided.
[in]keyto use to lookup cache entry
[in]key_lenthe length of the key string.
Returns

Definition at line 96 of file rlm_cache_redis.c.

+ Here is the call graph for this function:

static void cache_entry_free ( rlm_cache_entry_t c)
static

Definition at line 87 of file rlm_cache_redis.c.

static cache_status_t cache_entry_insert ( UNUSED rlm_cache_config_t const *  config,
void *  driver_inst,
REQUEST request,
UNUSED void *  handle,
const rlm_cache_entry_t c 
)
static

Insert a new entry into the data store.

Serialize (if necessary) the entry passed to us, and write it to the cache with the key c->key.

The cache entry should not be freed by the driver, irrespective of success or failure. If the entry needs to be freed after insertion because a local copy should not be kept, the driver should provide a cache_entry_free_t callback.

If the rlm_cache_handle_t is inviable, the driver should return CACHE_RECONNECT, to have it reinitialised/reconnected.

Note
This callback is not optional.
This callback must overwrite existing cache entries on insert.
Parameters
configfor this instance of the rlm_cache module.
driver_instDriver specific instance data.
requestThe current request.
handlethe driver gave us when we called cache_acquire_t, or NULL if no cache_acquire_t callback was provided.
cto insert.
Returns

Definition at line 233 of file rlm_cache_redis.c.

+ Here is the call graph for this function:

static int mod_instantiate ( CONF_SECTION conf,
rlm_cache_config_t const *  config,
void *  driver_inst 
)
static

Create a new rlm_cache_redis instance.

Function to handle any driver specific instantiation.

Parameters
confsection holding driver specific CONF_PAIR (s).
configof the rlm_cache module. Should not be modified.
driver_instA uint8_t array of inst_size if inst_size > 0, else NULL. Drivers should add their own cleanup function to this chunk using talloc_set_destructor.
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 50 of file rlm_cache_redis.c.

+ Here is the call graph for this function:

Variable Documentation

CONF_PARSER driver_config[]
static
Initial value:
= {
}
#define CONF_PARSER_TERMINATOR
Definition: conffile.h:289
#define REDIS_COMMON_CONFIG
Definition: redis.h:106

Definition at line 31 of file rlm_cache_redis.c.

Initial value:
= {
.name = "rlm_cache_redis",
.instantiate = mod_instantiate,
.inst_size = sizeof(rlm_cache_redis_t),
.insert = cache_entry_insert,
.expire = cache_entry_expire,
}
static cache_status_t cache_entry_insert(UNUSED rlm_cache_config_t const *config, void *driver_inst, REQUEST *request, UNUSED void *handle, const rlm_cache_entry_t *c)
Insert a new entry into the data store.
static cache_status_t cache_entry_find(rlm_cache_entry_t **out, UNUSED rlm_cache_config_t const *config, void *driver_inst, REQUEST *request, UNUSED void *handle, uint8_t const *key, size_t key_len)
Locate a cache entry in redis.
static int mod_instantiate(CONF_SECTION *conf, rlm_cache_config_t const *config, void *driver_inst)
Create a new rlm_cache_redis instance.
struct rlm_cache_redis rlm_cache_redis_t
static void cache_entry_free(rlm_cache_entry_t *c)
static cache_status_t cache_entry_expire(UNUSED rlm_cache_config_t const *config, void *driver_inst, REQUEST *request, UNUSED void *handle, uint8_t const *key, size_t key_len)
Call delete the cache entry from redis.

Definition at line 452 of file rlm_cache_redis.c.