MCPcopy Create free account
hub / github.com/1a1a11a/libCacheSim / clone_cache

Function clone_cache

libCacheSim/cache/cache.c:90–106  ·  view source on GitHub ↗

* @brief create a new cache with the same size as the old cache * * @param old_cache * @param new_size * @return cache_t* */

Source from the content-addressed store, hash-verified

88 * @return cache_t*
89 */
90cache_t *clone_cache(const cache_t *old_cache) {
91 common_cache_params_t cc_params = {
92 .cache_size = old_cache->cache_size,
93 .hashpower = old_cache->hashtable->hashpower,
94 .default_ttl = old_cache->default_ttl,
95 .consider_obj_metadata = old_cache->obj_md_size == 0 ? false : true,
96 };
97 assert(sizeof(cc_params) == 24);
98 cache_t *cache = old_cache->cache_init(cc_params, old_cache->init_params);
99 if (old_cache->admissioner != NULL) {
100 cache->admissioner = old_cache->admissioner->clone(old_cache->admissioner);
101 }
102 cache->future_stack_dist = old_cache->future_stack_dist;
103 cache->future_stack_dist_array_size = old_cache->future_stack_dist_array_size;
104
105 return cache;
106}
107/**
108 * @brief this function is called by all eviction algorithms to clone old cache
109 * with new size

Callers 1

CacheMethod · 0.85

Calls 1

assertFunction · 0.85

Tested by

no test coverage detected