MCPcopy Create free account
hub / github.com/RedisGraph/RedisGraph / Cache_SetGetValue

Function Cache_SetGetValue

src/util/cache/cache.c:124–146  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

122}
123
124void *Cache_SetGetValue(Cache *cache, const char *key, void *value) {
125 ASSERT(key != NULL);
126 ASSERT(cache != NULL);
127
128 size_t key_len = strlen(key);
129 void *value_to_return = value;
130
131 // acquire WRITE lock
132 int res = pthread_rwlock_wrlock(&cache->_cache_rwlock);
133 UNUSED(res);
134 ASSERT(res == 0);
135
136 // return true if value was added, false if value already in cache
137 if(_Cache_SetValue(cache, key, value, key_len)) {
138 // return a copy of original value
139 value_to_return = cache->copy_item(value);
140 }
141
142 res = pthread_rwlock_unlock(&cache->_cache_rwlock);
143 ASSERT(res == 0);
144
145 return value_to_return;
146}
147
148void Cache_Free(Cache *cache) {
149 ASSERT(cache != NULL);

Callers 2

ExecutionCtx_FromQueryFunction · 0.85
test_executionPlanCacheFunction · 0.85

Calls 1

_Cache_SetValueFunction · 0.85

Tested by 1

test_executionPlanCacheFunction · 0.68