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

Function Cache_GetValue

src/util/cache/cache.c:78–104  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

76}
77
78void *Cache_GetValue(Cache *cache, const char *key) {
79 void *item = NULL;
80
81 ASSERT(cache != NULL);
82
83 int res = pthread_rwlock_rdlock(&cache->_cache_rwlock);
84 UNUSED(res);
85 ASSERT(res == 0);
86
87 size_t key_len = strlen(key);
88 CacheEntry *entry = raxFind(cache->lookup, (unsigned char *)key, key_len);
89
90 if(entry == raxNotFound) goto cleanup;
91
92 // element is now the most recently used; update its LRU
93 // note that multiple threads can be here simultaneously
94 cache->counter++;
95 entry->LRU = cache->counter;
96
97 // return a copy of element
98 item = cache->copy_item(entry->value);
99
100cleanup:
101 res = pthread_rwlock_unlock(&cache->_cache_rwlock);
102 ASSERT(res == 0);
103 return item;
104}
105
106void Cache_SetValue(Cache *cache, const char *key, void *value) {
107 ASSERT(key != NULL);

Callers 2

ExecutionCtx_FromQueryFunction · 0.85
test_executionPlanCacheFunction · 0.85

Calls

no outgoing calls

Tested by 1

test_executionPlanCacheFunction · 0.68