Macros, functions and structures used to implement and use c-icap cache.
More...
|
void | ci_cache_type_register (const struct ci_cache_type *type) |
| Register a cache type to c-icap server.
|
|
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. 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.
|
|
Macros, functions and structures used to implement and use c-icap cache.
A struct which implements a cache type.
Modules implement a cache type, needs to implement members of this structure.
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_type | The cache type to use. If the cache type not found return a cache object of type "local" |
cache_size | The size of the cache |
max_object_size | The maximum object size to store in cache |
ttl | The ttl value for cached items in this cache |
key_ops | If not null, the ci_types_ops_t object to use for comparing keys. By default keys are considered as c strings. |
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
-
cache | Pointer to the ci_cache_t object |
key | Pointer to the key to search for |
val | Pointer to store the pointer of returned value |
data | Pointer to void object which will be passed to dup_from_cache function |
dup_from_cache | Pointer to function which will be used to allocate memory and copy the stored value. |
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
-
cache | Pointer to the ci_cache_t object |
key | The key of the stored object |
val | Pointer to the object to be stored |
val_size | The size of the object to be stored |
copy_to_cache | The function to use to copy object to cache. If it is NULL the memcpy is used. |