Back to Ccv

lib/ccv_cache.c

site/0.6/lib/ccv-cache/index.html

latest1.6 KB
Original Source

lib/ccv_cache.c

This class implements a trie-based LRU cache that is then used for ccv application-wide cache in ccv_memory.c.

ccv_cache_init

void ccv_cache_init(ccv_cache_t* cache, ccv_cache_index_free_f ffree, size_t up)

Setup a cache strcture to work with.

  • cache : the allocated cache.
  • ffree : the function that will be used to free cached object.
  • up : the upper limit of cache size in bytes.

ccv_cache_get

void* ccv_cache_get(ccv_cache_t* cache, uint64_t sign)

Get an object from cache for its signature. 0 if cannot find the object.

  • cache : the cache.
  • sign : the signature.

ccv_cache_out

void* ccv_cache_out(ccv_cache_t* cache, uint64_t sign)

Get an object from cache for its signature and then remove that object from the cache. 0 if cannot find the object.

  • cache : the cache.
  • sign : the signature.

ccv_cache_delete

int ccv_cache_delete(ccv_cache_t* cache, uint64_t sign)

Delete an object from cache for its signature and free it. Return -1 if cannot find the object, otherwise return 0.

  • cache : the cache.
  • sign : the signature.

ccv_cache_cleanup

void ccv_cache_cleanup(ccv_cache_t* cache)

Clean up the cache, free all objects inside and other memory space occupied.

  • cache : the cache.

ccv_cache_close

void ccv_cache_close(ccv_cache_t* cache)

For current implementation (trie-based LRU cache), it is an alias for ccv_cache_cleanup.

  • cache : the cache.

‹ back

comments powered by Disqus