The FreeRADIUS server  $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Data Structures | Macros | Functions | Variables
rlm_cache_redis.c File Reference

redis based cache. More...

#include <freeradius-devel/server/base.h>
#include <freeradius-devel/util/debug.h>
#include <freeradius-devel/util/value.h>
#include "../../rlm_cache.h"
#include <freeradius-devel/redis/base.h>
#include <freeradius-devel/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_t
 

Macros

#define LOG_PREFIX   "cache - redis"
 

Functions

static cache_status_t cache_entry_expire (UNUSED rlm_cache_config_t const *config, void *instance, request_t *request, UNUSED void *handle, fr_value_box_t const *key)
 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 *instance, request_t *request, UNUSED void *handle, fr_value_box_t const *key)
 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 *instance, request_t *request, UNUSED void *handle, const rlm_cache_entry_t *c)
 Insert a new entry into the data store. More...
 
static int mod_instantiate (module_inst_ctx_t const *mctx)
 Create a new rlm_cache_redis instance. More...
 
static int mod_load (void)
 

Variables

static fr_dict_attr_t const * attr_cache_created
 
static fr_dict_attr_t const * attr_cache_expires
 
static fr_dict_t const * dict_freeradius
 
static conf_parser_t driver_config []
 
rlm_cache_driver_t rlm_cache_redis
 
fr_dict_autoload_t rlm_cache_redis_dict []
 
fr_dict_attr_autoload_t rlm_cache_redis_dict_attr []
 

Detailed Description

redis based cache.

Id
d5ad02d98725df5611c7d6fdc5b7d7727500418b

Definition in file rlm_cache_redis.c.


Data Structure Documentation

◆ rlm_cache_redis_t

struct rlm_cache_redis_t

Definition at line 38 of file rlm_cache_redis.c.

+ Collaboration diagram for rlm_cache_redis_t:
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.

tmpl_t * created_attr LHS of the Cache-Created map.
tmpl_t * expires_attr LHS of the Cache-Expires map.

Macro Definition Documentation

◆ LOG_PREFIX

#define LOG_PREFIX   "cache - redis"

Definition at line 24 of file rlm_cache_redis.c.

Function Documentation

◆ cache_entry_expire()

static cache_status_t cache_entry_expire ( UNUSED rlm_cache_config_t const *  config,
void *  instance,
request_t request,
UNUSED void *  handle,
fr_value_box_t const *  key 
)
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]instanceDriver 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.
Returns

Definition at line 432 of file rlm_cache_redis.c.

+ Here is the call graph for this function:

◆ cache_entry_find()

static cache_status_t cache_entry_find ( rlm_cache_entry_t **  out,
UNUSED rlm_cache_config_t const *  config,
void *  instance,
request_t request,
UNUSED void *  handle,
fr_value_box_t const *  key 
)
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]instanceDriver 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
Returns

Definition at line 123 of file rlm_cache_redis.c.

+ Here is the call graph for this function:

◆ cache_entry_free()

static void cache_entry_free ( rlm_cache_entry_t c)
static

Definition at line 114 of file rlm_cache_redis.c.

+ Here is the call graph for this function:

◆ cache_entry_insert()

static cache_status_t cache_entry_insert ( UNUSED rlm_cache_config_t const *  config,
void *  instance,
request_t 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.
instanceDriver 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 253 of file rlm_cache_redis.c.

+ Here is the call graph for this function:

◆ mod_instantiate()

static int mod_instantiate ( module_inst_ctx_t const *  mctx)
static

Create a new rlm_cache_redis instance.

Parameters
[in]mctxData required for instantiation.
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 73 of file rlm_cache_redis.c.

+ Here is the call graph for this function:

◆ mod_load()

static int mod_load ( void  )
static

Definition at line 108 of file rlm_cache_redis.c.

+ Here is the call graph for this function:

Variable Documentation

◆ attr_cache_created

fr_dict_attr_t const* attr_cache_created
static

Definition at line 56 of file rlm_cache_redis.c.

◆ attr_cache_expires

fr_dict_attr_t const* attr_cache_expires
static

Definition at line 57 of file rlm_cache_redis.c.

◆ dict_freeradius

fr_dict_t const* dict_freeradius
static

Definition at line 48 of file rlm_cache_redis.c.

◆ driver_config

conf_parser_t driver_config[]
static
Initial value:
= {
}
#define CONF_PARSER_TERMINATOR
Definition: cf_parse.h:627
#define REDIS_COMMON_CONFIG
Definition: base.h:133

Definition at line 33 of file rlm_cache_redis.c.

◆ rlm_cache_redis

rlm_cache_driver_t rlm_cache_redis
Initial value:
= {
.common = {
.name = "cache_redis",
.onload = mod_load,
.instantiate = mod_instantiate,
.inst_size = sizeof(rlm_cache_redis_t),
},
.insert = cache_entry_insert,
.expire = cache_entry_expire,
}
#define MODULE_MAGIC_INIT
Stop people using different module/library/server versions together.
Definition: dl_module.h:63
static const conf_parser_t config[]
Definition: base.c:183
static cache_status_t cache_entry_insert(UNUSED rlm_cache_config_t const *config, void *instance, request_t *request, UNUSED void *handle, const rlm_cache_entry_t *c)
Insert a new entry into the data store.
static int mod_load(void)
static void cache_entry_free(rlm_cache_entry_t *c)
static conf_parser_t driver_config[]
static cache_status_t cache_entry_expire(UNUSED rlm_cache_config_t const *config, void *instance, request_t *request, UNUSED void *handle, fr_value_box_t const *key)
Call delete the cache entry from redis.
static cache_status_t cache_entry_find(rlm_cache_entry_t **out, UNUSED rlm_cache_config_t const *config, void *instance, request_t *request, UNUSED void *handle, fr_value_box_t const *key)
Locate a cache entry in redis.
static int mod_instantiate(module_inst_ctx_t const *mctx)
Create a new rlm_cache_redis instance.

Definition at line 473 of file rlm_cache_redis.c.

◆ rlm_cache_redis_dict

fr_dict_autoload_t rlm_cache_redis_dict
Initial value:
= {
{ .out = &dict_freeradius, .proto = "freeradius" },
{ NULL }
}
static fr_dict_t const * dict_freeradius

Definition at line 51 of file rlm_cache_redis.c.

◆ rlm_cache_redis_dict_attr

fr_dict_attr_autoload_t rlm_cache_redis_dict_attr
Initial value:
= {
{ .out = &attr_cache_created, .name = "Cache-Created", .type = FR_TYPE_DATE, .dict = &dict_freeradius },
{ .out = &attr_cache_expires, .name = "Cache-Expires", .type = FR_TYPE_DATE, .dict = &dict_freeradius },
{ NULL }
}
@ FR_TYPE_DATE
Unix time stamp, always has value >2^31.
Definition: merged_model.c:111
static fr_dict_attr_t const * attr_cache_created
static fr_dict_attr_t const * attr_cache_expires

Definition at line 60 of file rlm_cache_redis.c.