gwenhywfar  5.11.1beta
Typedefs | Functions
memcache.h File Reference
#include <gwenhywfar/gwenhywfarapi.h>
#include <time.h>
#include <inttypes.h>

Go to the source code of this file.

Typedefs

typedef struct GWEN_MEMCACHE GWEN_MEMCACHE
 
typedef struct GWEN_MEMCACHE_ENTRY GWEN_MEMCACHE_ENTRY
 

Functions

GWENHYWFAR_API GWEN_MEMCACHE_ENTRYGWEN_MemCache_CreateEntry (GWEN_MEMCACHE *mc, uint32_t id, void *dataPtr, size_t dataLen)
 
GWENHYWFAR_API GWEN_MEMCACHE_ENTRYGWEN_MemCache_FindEntry (GWEN_MEMCACHE *mc, uint32_t id)
 
GWENHYWFAR_API void GWEN_MemCache_free (GWEN_MEMCACHE *mc)
 
GWENHYWFAR_API GWEN_MEMCACHEGWEN_MemCache_new (size_t maxCacheMemory, uint32_t maxCacheEntries)
 
GWENHYWFAR_API void GWEN_MemCache_Purge (GWEN_MEMCACHE *mc)
 
GWENHYWFAR_API void GWEN_MemCache_PurgeEntries (GWEN_MEMCACHE *mc, uint32_t id, uint32_t mask)
 
GWENHYWFAR_API void GWEN_MemCache_PurgeEntry (GWEN_MEMCACHE *mc, uint32_t id)
 
GWENHYWFAR_API void GWEN_MemCacheEntry_BeginUse (GWEN_MEMCACHE_ENTRY *me)
 
GWENHYWFAR_API void GWEN_MemCacheEntry_EndUse (GWEN_MEMCACHE_ENTRY *me)
 
GWENHYWFAR_API void GWEN_MemCacheEntry_free (GWEN_MEMCACHE_ENTRY *me)
 
GWENHYWFAR_API size_t GWEN_MemCacheEntry_GetDataLen (GWEN_MEMCACHE_ENTRY *me)
 
GWENHYWFAR_API void * GWEN_MemCacheEntry_GetDataPtr (GWEN_MEMCACHE_ENTRY *me)
 
GWENHYWFAR_API uint32_t GWEN_MemCacheEntry_GetId (GWEN_MEMCACHE_ENTRY *me)
 
GWENHYWFAR_API int GWEN_MemCacheEntry_GetIsValid (const GWEN_MEMCACHE_ENTRY *me)
 

Typedef Documentation

◆ GWEN_MEMCACHE

typedef struct GWEN_MEMCACHE GWEN_MEMCACHE

Definition at line 1 of file memcache.h.

◆ GWEN_MEMCACHE_ENTRY

Definition at line 1 of file memcache.h.

Function Documentation

◆ GWEN_MemCache_CreateEntry()

GWENHYWFAR_API GWEN_MEMCACHE_ENTRY* GWEN_MemCache_CreateEntry ( GWEN_MEMCACHE mc,
uint32_t  id,
void *  dataPtr,
size_t  dataLen 
)

Creates a cache entry for the given id. If there already is an entry of the given id that existing entry will first be invalidated. The use counter of the new object returned is 1, so the caller must call GWEN_MemCacheEntry_EndUse after working with the object returned in order to release unused cache entries.

◆ GWEN_MemCache_FindEntry()

GWENHYWFAR_API GWEN_MEMCACHE_ENTRY* GWEN_MemCache_FindEntry ( GWEN_MEMCACHE mc,
uint32_t  id 
)

Returns the cache entry with the given id (if any). If NULL is returned then there is no entry with the given id, otherwise the use counter of the object returned is incremented. Therefore the caller has to call GWEN_MemCacheEntry_EndUse after working with the object returned in order to release unused cache entries.

◆ GWEN_MemCache_free()

GWENHYWFAR_API void GWEN_MemCache_free ( GWEN_MEMCACHE mc)

◆ GWEN_MemCache_new()

GWENHYWFAR_API GWEN_MEMCACHE* GWEN_MemCache_new ( size_t  maxCacheMemory,
uint32_t  maxCacheEntries 
)

◆ GWEN_MemCache_Purge()

GWENHYWFAR_API void GWEN_MemCache_Purge ( GWEN_MEMCACHE mc)

This function invalidates all cache entries. See GWEN_MemCache_PurgeEntry for implementation details and caveats.

◆ GWEN_MemCache_PurgeEntries()

GWENHYWFAR_API void GWEN_MemCache_PurgeEntries ( GWEN_MEMCACHE mc,
uint32_t  id,
uint32_t  mask 
)

This function invalidates all entries whose ids match the given id/mask pair. See GWEN_MemCache_PurgeEntry for implementation details and caveats.

◆ GWEN_MemCache_PurgeEntry()

GWENHYWFAR_API void GWEN_MemCache_PurgeEntry ( GWEN_MEMCACHE mc,
uint32_t  id 
)

This function invalidates a given cache entry (if it exists). The data associated with that entry is not freed yet until all users of that entry called GWEN_MemCacheEntry_EndUse (i.e. until the use counter of that entry reaches zero). However, the entry will be removed from the cache index so that future calls to GWEN_MemCache_FindEntry will not return it.

◆ GWEN_MemCacheEntry_BeginUse()

GWENHYWFAR_API void GWEN_MemCacheEntry_BeginUse ( GWEN_MEMCACHE_ENTRY me)

◆ GWEN_MemCacheEntry_EndUse()

GWENHYWFAR_API void GWEN_MemCacheEntry_EndUse ( GWEN_MEMCACHE_ENTRY me)

◆ GWEN_MemCacheEntry_free()

GWENHYWFAR_API void GWEN_MemCacheEntry_free ( GWEN_MEMCACHE_ENTRY me)

◆ GWEN_MemCacheEntry_GetDataLen()

GWENHYWFAR_API size_t GWEN_MemCacheEntry_GetDataLen ( GWEN_MEMCACHE_ENTRY me)

◆ GWEN_MemCacheEntry_GetDataPtr()

GWENHYWFAR_API void* GWEN_MemCacheEntry_GetDataPtr ( GWEN_MEMCACHE_ENTRY me)

◆ GWEN_MemCacheEntry_GetId()

GWENHYWFAR_API uint32_t GWEN_MemCacheEntry_GetId ( GWEN_MEMCACHE_ENTRY me)

◆ GWEN_MemCacheEntry_GetIsValid()

GWENHYWFAR_API int GWEN_MemCacheEntry_GetIsValid ( const GWEN_MEMCACHE_ENTRY me)