memcache.c File Reference

#include "memcache_p.h"
#include <gwenhywfar/misc.h>
#include <gwenhywfar/debug.h>

Go to the source code of this file.

Functions

int GWEN_MemCache__MakeRoom (GWEN_MEMCACHE *mc, size_t neededSize)
GWEN_MEMCACHE_ENTRYGWEN_MemCache_CreateEntry (GWEN_MEMCACHE *mc, uint32_t id, void *dataPtr, size_t dataLen)
GWEN_MEMCACHE_ENTRYGWEN_MemCache_FindEntry (GWEN_MEMCACHE *mc, uint32_t id)
void GWEN_MemCache_free (GWEN_MEMCACHE *mc)
int GWEN_MemCache_Lock (GWEN_MEMCACHE *mc)
GWEN_MEMCACHEGWEN_MemCache_new (size_t maxCacheMemory, uint32_t maxCacheEntries)
void GWEN_MemCache_Purge (GWEN_MEMCACHE *mc)
void GWEN_MemCache_PurgeEntries (GWEN_MEMCACHE *mc, uint32_t id, uint32_t mask)
void GWEN_MemCache_PurgeEntry (GWEN_MEMCACHE *mc, uint32_t id)
int GWEN_MemCache_Unlock (GWEN_MEMCACHE *mc)
void GWEN_MemCacheEntry_BeginUse (GWEN_MEMCACHE_ENTRY *me)
void GWEN_MemCacheEntry_EndUse (GWEN_MEMCACHE_ENTRY *me)
void GWEN_MemCacheEntry_free (GWEN_MEMCACHE_ENTRY *me)
size_t GWEN_MemCacheEntry_GetDataLen (GWEN_MEMCACHE_ENTRY *me)
void * GWEN_MemCacheEntry_GetDataPtr (GWEN_MEMCACHE_ENTRY *me)
uint32_t GWEN_MemCacheEntry_GetId (GWEN_MEMCACHE_ENTRY *me)
time_t GWEN_MemCacheEntry_GetUnusedSince (GWEN_MEMCACHE_ENTRY *me)
int GWEN_MemCacheEntry_GetUseCounter (const GWEN_MEMCACHE_ENTRY *me)
GWEN_MEMCACHE_ENTRYGWEN_MemCacheEntry_new (GWEN_MEMCACHE *memCache, uint32_t id, void *dataPtr, size_t dataLen)


Function Documentation

int GWEN_MemCache__MakeRoom ( GWEN_MEMCACHE mc,
size_t  neededSize 
)

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.

Definition at line 275 of file memcache.c.

References DBG_WARN, GWEN_LOGDOMAIN, GWEN_MemCache__MakeRoom(), GWEN_MemCache_Lock(), GWEN_MemCache_Unlock(), GWEN_MemCacheEntry_free(), GWEN_MemCacheEntry_new(), and NULL.

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.

Definition at line 189 of file memcache.c.

References GWEN_MemCache_Lock(), and GWEN_MemCache_Unlock().

void GWEN_MemCache_free ( GWEN_MEMCACHE mc  ) 

Definition at line 179 of file memcache.c.

References GWEN_FREE_OBJECT, and GWEN_Mutex_free().

int GWEN_MemCache_Lock ( GWEN_MEMCACHE mc  ) 

GWEN_MEMCACHE* GWEN_MemCache_new ( size_t  maxCacheMemory,
uint32_t  maxCacheEntries 
)

Definition at line 164 of file memcache.c.

References GWEN_IdMapAlgo_Hex4, GWEN_Mutex_new(), and GWEN_NEW_OBJECT.

void GWEN_MemCache_Purge ( GWEN_MEMCACHE mc  ) 

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

Definition at line 368 of file memcache.c.

References GWEN_MemCache_PurgeEntries().

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.

Definition at line 334 of file memcache.c.

References GWEN_IdMapResult_Ok, GWEN_MemCache_Lock(), GWEN_MemCache_Unlock(), and GWEN_MemCacheEntry_free().

Referenced by GWEN_MemCache_Purge().

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.

Definition at line 207 of file memcache.c.

References GWEN_MemCache_Lock(), GWEN_MemCache_Unlock(), and GWEN_MemCacheEntry_free().

int GWEN_MemCache_Unlock ( GWEN_MEMCACHE mc  ) 

void GWEN_MemCacheEntry_BeginUse ( GWEN_MEMCACHE_ENTRY me  ) 

Definition at line 116 of file memcache.c.

References DBG_INFO, GWEN_LOGDOMAIN, GWEN_MemCache_Lock(), and GWEN_MemCache_Unlock().

void GWEN_MemCacheEntry_EndUse ( GWEN_MEMCACHE_ENTRY me  ) 

void GWEN_MemCacheEntry_free ( GWEN_MEMCACHE_ENTRY me  ) 

size_t GWEN_MemCacheEntry_GetDataLen ( GWEN_MEMCACHE_ENTRY me  ) 

Definition at line 109 of file memcache.c.

void* GWEN_MemCacheEntry_GetDataPtr ( GWEN_MEMCACHE_ENTRY me  ) 

Definition at line 102 of file memcache.c.

uint32_t GWEN_MemCacheEntry_GetId ( GWEN_MEMCACHE_ENTRY me  ) 

Definition at line 95 of file memcache.c.

time_t GWEN_MemCacheEntry_GetUnusedSince ( GWEN_MEMCACHE_ENTRY me  ) 

Definition at line 88 of file memcache.c.

int GWEN_MemCacheEntry_GetUseCounter ( const GWEN_MEMCACHE_ENTRY me  ) 

Definition at line 81 of file memcache.c.

GWEN_MEMCACHE_ENTRY* GWEN_MemCacheEntry_new ( GWEN_MEMCACHE memCache,
uint32_t  id,
void *  dataPtr,
size_t  dataLen 
)

Definition at line 40 of file memcache.c.

References GWEN_NEW_OBJECT.

Referenced by GWEN_MemCache_CreateEntry().


Generated on Thu Aug 20 13:54:41 2009 for gwenhywfar by  doxygen 1.5.9