A Modern Computer Vision Library
This class implements a trie-based lru cache that is then used for ccv application-wide cache in ccv_memory.c.
void ccv_cache_init(ccv_cache_t *cache, size_t up, int cache_types, ccv_cache_index_free_f ffree,...)
Setup a cache strcture to work with.
void* ccv_cache_get(ccv_cache_t *cache, uint64_t sign, uint8_t *type)
Get an object from cache for its signature. 0 if cannot find the object.
return: The pointer to the object.
int ccv_cache_put(ccv_cache_t *cache, uint64_t sign, void *x, uint32_t size, uint8_t type)
Put an object to cache with its signature, size, and type
return: 0 - success, 1 - replace, -1 - failure.
void* ccv_cache_out(ccv_cache_t *cache, uint64_t sign, uint8_t *type)
Get an object from cache for its signature and then remove that object from the cache. 0 if cannot find the object.
return: The pointer to the object.
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.
void ccv_cache_cleanup(ccv_cache_t *cache)
Clean up the cache, free all objects inside and other memory space occupied.
void ccv_cache_close(ccv_cache_t *cache)
For current implementation (trie-based LRU cache), it is an alias for ccv_cache_cleanup.