ChibiOS
21.6.0
|
Objects Caches code. More...
#include "ch.h"
Go to the source code of this file.
Functions | |
static oc_object_t * | hash_get_s (objects_cache_t *ocp, uint32_t group, uint32_t key) |
Returns an object pointer from the cache, if present. More... | |
static oc_object_t * | lru_get_last_s (objects_cache_t *ocp) |
Gets the least recently used object buffer from the LRU list. More... | |
void | chCacheObjectInit (objects_cache_t *ocp, ucnt_t hashn, oc_hash_header_t *hashp, ucnt_t objn, size_t objsz, void *objvp, oc_readf_t readf, oc_writef_t writef) |
Initializes a objects_cache_t object. More... | |
oc_object_t * | chCacheGetObject (objects_cache_t *ocp, uint32_t group, uint32_t key) |
Retrieves an object from the cache. More... | |
void | chCacheReleaseObjectI (objects_cache_t *ocp, oc_object_t *objp) |
Releases an object into the cache. More... | |
bool | chCacheReadObject (objects_cache_t *ocp, oc_object_t *objp, bool async) |
Reads object data from the storage. More... | |
bool | chCacheWriteObject (objects_cache_t *ocp, oc_object_t *objp, bool async) |
Writes the object data back to storage. More... | |
Objects Caches code.
Objects caches.
An object cache allows to retrieve and release objects from a slow media, for example a disk or flash.
The most recently used objects are kept in a series of RAM buffers making access faster. Objects are identified by a pair <group, key> which could be mapped, for example, to a disk drive identifier and sector identifier.
Read and write operations are performed using externally-supplied functions, the cache is device-agnostic.
The cache uses internally an hash table, the size of the table should be dimensioned to minimize the risk of hash collisions, a factor of two is usually acceptable, it depends on the specific application requirements.
Operations defined for caches:
CH_CFG_USE_OBJ_CACHES
option must be enabled in chconf.h
. Definition in file chobjcaches.c.