c-icap-doc  0.1
Data Structures | Typedefs | Functions


Macros, functions and structures used to implement and use c-icap cache. More...

Data Structures

struct  ci_cache_type
 
A struct which implements a cache type. More...
 
struct  ci_cache
 
The ci_cache_t struct More...
 

Typedefs

typedef struct ci_cache_type ci_cache_type_t
 
A struct which implements a cache type. More...
 
typedef struct ci_cache ci_cache_t
 
The ci_cache_t struct
 

Functions

void ci_cache_type_register (const struct ci_cache_type *type)
 
Register a cache type to c-icap server.
 
ci_cache_tci_cache_build (const char *name, const char *cache_type, unsigned int cache_size, unsigned int max_object_size, int ttl, const ci_type_ops_t *key_ops)
 
Builds a cache and return a pointer to the ci_cache_t object More...
 
const void * ci_cache_search (ci_cache_t *cache, const void *key, void **val, void *data, void *(*dup_from_cache)(const void *stored_val, size_t stored_val_size, void *data))
 
Searchs a cache for a stored object If the dup_from_cache parameter is NULL, the returned value must be released using the ci_buffer_free function. More...
 
int ci_cache_update (ci_cache_t *cache, const void *key, const void *val, size_t val_size, void *(*copy_to_cache)(void *buf, const void *val, size_t buf_size))
 
Stores an object to cache More...
 
void ci_cache_destroy (ci_cache_t *cache)
 
Destroy a cache_t object
 

Detailed Description


Macros, functions and structures used to implement and use c-icap cache.

Typedef Documentation

◆ ci_cache_type_t


A struct which implements a cache type.

Modules implement a cache type, needs to implement members of this structure.

Function Documentation

◆ ci_cache_build()

ci_cache_t* ci_cache_build ( const char *  name,
const char *  cache_type,
unsigned int  cache_size,
unsigned int  max_object_size,
int  ttl,
const ci_type_ops_t *  key_ops 
)


Builds a cache and return a pointer to the ci_cache_t object

Parameters
cache_typeThe cache type to use. If the cache type not found return a cache object of type "local"
cache_sizeThe size of the cache
max_object_sizeThe maximum object size to store in cache
ttlThe ttl value for cached items in this cache
key_opsIf not null, the ci_types_ops_t object to use for comparing keys. By default keys are considered as c strings.

◆ ci_cache_search()

const void* ci_cache_search ( ci_cache_t cache,
const void *  key,
void **  val,
void *  data,
void *(*)(const void *stored_val, size_t stored_val_size, void *data)  dup_from_cache 
)


Searchs a cache for a stored object If the dup_from_cache parameter is NULL, the returned value must be released using the ci_buffer_free function.

Parameters
cachePointer to the ci_cache_t object
keyPointer to the key to search for
valPointer to store the pointer of returned value
dataPointer to void object which will be passed to dup_from_cache function
dup_from_cachePointer to function which will be used to allocate memory and copy the stored value.

◆ ci_cache_update()

int ci_cache_update ( ci_cache_t cache,
const void *  key,
const void *  val,
size_t  val_size,
void *(*)(void *buf, const void *val, size_t buf_size)  copy_to_cache 
)


Stores an object to cache

Parameters
cachePointer to the ci_cache_t object
keyThe key of the stored object
valPointer to the object to be stored
val_sizeThe size of the object to be stored
copy_to_cacheThe function to use to copy object to cache. If it is NULL the memcpy is used.