memcached based cache. More...
#include <libmemcached/memcached.h>
#include <freeradius-devel/radiusd.h>
#include <freeradius-devel/modules.h>
#include <freeradius-devel/rad_assert.h>
#include "../../rlm_cache.h"
#include "../../serialize.h"
Go to the source code of this file.
Data Structures | |
struct | rlm_cache_memcached |
struct | rlm_cache_memcached_handle |
Typedefs | |
typedef struct rlm_cache_memcached_handle | rlm_cache_memcached_handle_t |
typedef struct rlm_cache_memcached | rlm_cache_memcached_t |
Functions | |
static int | _mod_conn_free (rlm_cache_memcached_handle_t *mandle) |
Free a connection handle. More... | |
static cache_status_t | cache_entry_expire (UNUSED rlm_cache_config_t const *config, UNUSED void *driver_inst, REQUEST *request, void *handle, uint8_t const *key, size_t key_len) |
Call delete the cache entry from memcached. More... | |
static cache_status_t | cache_entry_find (rlm_cache_entry_t **out, UNUSED rlm_cache_config_t const *config, UNUSED void *driver_inst, REQUEST *request, void *handle, uint8_t const *key, size_t key_len) |
Locate a cache entry in memcached. More... | |
static void | cache_entry_free (rlm_cache_entry_t *c) |
Locate a cache entry in memcached. More... | |
static cache_status_t | cache_entry_insert (UNUSED rlm_cache_config_t const *config, UNUSED void *driver_inst, REQUEST *request, void *handle, const rlm_cache_entry_t *c) |
Insert a new entry into the data store. More... | |
static void * | mod_conn_create (TALLOC_CTX *ctx, void *instance, struct timeval const *timeout) |
Create a new memcached handle. More... | |
static int | mod_conn_get (void **handle, UNUSED rlm_cache_config_t const *config, void *driver_inst, UNUSED REQUEST *request) |
Get a memcached handle. More... | |
static int | mod_conn_reconnect (void **handle, UNUSED rlm_cache_config_t const *config, void *driver_inst, UNUSED REQUEST *request) |
Reconnect a memcached handle. More... | |
static void | mod_conn_release (UNUSED rlm_cache_config_t const *config, void *driver_inst, UNUSED REQUEST *request, rlm_cache_handle_t *handle) |
Release a memcached handle. More... | |
static int | mod_instantiate (CONF_SECTION *conf, rlm_cache_config_t const *config, void *driver_inst) |
Create a new rlm_cache_memcached instance. More... | |
Variables | |
static const CONF_PARSER | driver_config [] |
cache_driver_t | rlm_cache_memcached |
memcached based cache.
Definition in file rlm_cache_memcached.c.
struct rlm_cache_memcached |
Definition at line 37 of file rlm_cache_memcached.c.
Data Fields | ||
---|---|---|
char const * | options | Connection options. |
fr_connection_pool_t * | pool |
struct rlm_cache_memcached_handle |
Definition at line 33 of file rlm_cache_memcached.c.
Data Fields | ||
---|---|---|
memcached_st * | handle |
typedef struct rlm_cache_memcached_handle rlm_cache_memcached_handle_t |
typedef struct rlm_cache_memcached rlm_cache_memcached_t |
|
static |
Free a connection handle.
mandle | to free. |
Definition at line 51 of file rlm_cache_memcached.c.
|
static |
Call delete the cache entry from memcached.
[in] | config | for this instance of the rlm_cache module. |
[in] | driver_inst | Driver specific instance data. |
[in] | request | The current request. |
[in] | handle | the driver gave us when we called cache_acquire_t, or NULL if no cache_acquire_t callback was provided. |
[in] | key | of entry to expire. |
[in] | key_len | the length of the key string. |
Definition at line 242 of file rlm_cache_memcached.c.
|
static |
Locate a cache entry in memcached.
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.
[out] | out | Where to write a pointer to the retrieved entry (if there was one). |
[in] | config | for this instance of the rlm_cache module. |
[in] | driver_inst | Driver specific instance data. |
[in] | request | The current request. |
[in] | handle | the driver gave us when we called cache_acquire_t, or NULL if no cache_acquire_t callback was provided. |
[in] | key | to use to lookup cache entry |
[in] | key_len | the length of the key string. |
Definition at line 160 of file rlm_cache_memcached.c.
|
static |
Locate a cache entry in memcached.
If the driver does not need to keep a local copy of the cache entry, it should provide a callback to free the memory previously allocated for the cache entry by cache_entry_find_t or by rlm_cache.
c | entry to free. |
Definition at line 151 of file rlm_cache_memcached.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.
config | for this instance of the rlm_cache module. |
driver_inst | Driver specific instance data. |
request | The current request. |
handle | the driver gave us when we called cache_acquire_t, or NULL if no cache_acquire_t callback was provided. |
c | to insert. |
Definition at line 205 of file rlm_cache_memcached.c.
|
static |
Create a new memcached handle.
Definition at line 61 of file rlm_cache_memcached.c.
|
static |
Get a memcached handle.
[out] | handle | Where to write pointer to handle to access the cache with. |
[in] | config | for this instance of the rlm_cache module. |
[in] | driver_inst | Driver specific instance data. |
[in] | request | The current request. |
Definition at line 267 of file rlm_cache_memcached.c.
|
static |
Reconnect a memcached handle.
[in,out] | handle | to reinitialise/reconnect. |
[in] | config | for this instance of the rlm_cache module. |
[in] | driver_inst | Driver specific instance data. |
[in] | request | The current request. |
Definition at line 301 of file rlm_cache_memcached.c.
|
static |
Release a memcached handle.
[in] | config | for this instance of the rlm_cache module. |
[in] | driver_inst | Driver specific instance data. |
[in] | request | The current request. |
[in] | handle | to release. |
Definition at line 289 of file rlm_cache_memcached.c.
|
static |
Create a new rlm_cache_memcached instance.
Function to handle any driver specific instantiation.
conf | section holding driver specific CONF_PAIR (s). |
config | of the rlm_cache module. Should not be modified. |
driver_inst | A 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. |
Definition at line 103 of file rlm_cache_memcached.c.
|
static |
Definition at line 42 of file rlm_cache_memcached.c.
Definition at line 318 of file rlm_cache_memcached.c.