fiftyoneDegreesCache * fiftyoneDegreesCacheCreate(uint32_t capacity, uint16_t concurrency, fiftyoneDegreesCacheLoadMethod load, fiftyoneDegreesCacheHashCodeMethod hash, const void *state)
Creates a new cache.The cache must be destroyed with the fiftyoneDegreesCacheFree method.
fiftyoneDegreesCacheNode * fiftyoneDegreesCacheGet(fiftyoneDegreesCache *cache, const void *key, fiftyoneDegreesException *exception)
Gets an item from the cache.
void fiftyoneDegreesCacheRelease(fiftyoneDegreesCacheNode *node)
Releases the cache node previous obtained via fiftyoneDegreesCacheGet so that it can be evicted from ...
int64_t fiftyoneDegreesCacheHash32(const void *key)
Passed a pointer to a 32 bit / 4 byte data structure and returns the data as a 64 bit / 8 byte value ...
void(* fiftyoneDegreesCacheLoadMethod)(const void *state, fiftyoneDegreesData *data, const void *key, fiftyoneDegreesException *exception)
Method used to load data into the cache.
Definition cache.h:173
int64_t fiftyoneDegreesCacheHash64(const void *key)
Passed a pointer to a 64 bit / 8 byte data structure and returns the data as a 64 bit / 8 byte value ...
int64_t(* fiftyoneDegreesCacheHashCodeMethod)(const void *key)
Method used to calculate a hash code from the key.
Definition cache.h:184
void fiftyoneDegreesCacheFree(fiftyoneDegreesCache *cache)
Frees the cache structure, all allocated nodes and their data.
pthread_mutex_t fiftyoneDegreesMutex
MUTEX AND THREADING MACROS.
Definition threading.h:98
Cache structure to store the root of the red black tree and a list of allocated cache nodes.
Definition cache.h:191
fiftyoneDegreesCacheShard * shards
Array of shards / concurrency.
Definition cache.h:192
fiftyoneDegreesCacheHashCodeMethod hash
Used to hash a key pointer.
Definition cache.h:200
unsigned long hits
The requests served from the cache.
Definition cache.h:196
const void * loaderState
Cache loader specific state.
Definition cache.h:201
uint16_t concurrency
Expected concurrency and number of shards.
Definition cache.h:194
unsigned long misses
The requests NOT served from the cache.
Definition cache.h:197
fiftyoneDegreesCacheNode * nodes
Array of nodes / capacity.
Definition cache.h:193
fiftyoneDegreesCacheLoadMethod load
Used by the cache to load an item into the cache.
Definition cache.h:198
Cache node structure used for storing data in the cache along with its key.
Definition cache.h:136
fiftyoneDegreesData data
Data contained in the node.
Definition cache.h:138
fiftyoneDegreesTreeNode tree
Tree node for this cache node.
Definition cache.h:137
fiftyoneDegreesCacheShard * shard
Shard the node is associated with.
Definition cache.h:139
fiftyoneDegreesCacheNode * listNext
Next node or NULL if last.
Definition cache.h:141
int activeCount
Number of external references to the node data.
Definition cache.h:142
fiftyoneDegreesCacheNode * listPrevious
Previous node or NULL if first.
Definition cache.h:140
Cache shard structure used to enable concurrent access to the cache.
Definition cache.h:148
fiftyoneDegreesCacheNode * first
Pointer to the first node in the linked list.
Definition cache.h:155
fiftyoneDegreesMutex lock
Used to ensure exclusive access to the shard for get and release operations.
Definition cache.h:160
fiftyoneDegreesCache * cache
Pointer to the cache to which the node belongs.
Definition cache.h:149
uint32_t allocated
Number of nodes currently used in the shard.
Definition cache.h:153
fiftyoneDegreesCacheNode * last
Pointer to the last node in the linked list.
Definition cache.h:157
fiftyoneDegreesTreeRoot root
Root node of the red black tree.
Definition cache.h:151
fiftyoneDegreesCacheNode * nodes
Pointer to the array of all nodes.
Definition cache.h:154
Data structure used for reusing memory which may have been allocated in a previous operation.
Definition data.h:105
Structure used to represent a 51Degrees exception and passed into methods that might generate excepti...
Definition exceptions.h:115
