| 104 | } |
| 105 | |
| 106 | void Cache_SetValue(Cache *cache, const char *key, void *value) { |
| 107 | ASSERT(key != NULL); |
| 108 | ASSERT(cache != NULL); |
| 109 | |
| 110 | size_t key_len = strlen(key); |
| 111 | |
| 112 | // Acquire WRITE lock |
| 113 | int res = pthread_rwlock_wrlock(&cache->_cache_rwlock); |
| 114 | UNUSED(res); |
| 115 | ASSERT(res == 0); |
| 116 | |
| 117 | // Insert the value to the cache. |
| 118 | _Cache_SetValue(cache, key, value, key_len); |
| 119 | |
| 120 | res = pthread_rwlock_unlock(&cache->_cache_rwlock); |
| 121 | ASSERT(res == 0); |
| 122 | } |
| 123 | |
| 124 | void *Cache_SetGetValue(Cache *cache, const char *key, void *value) { |
| 125 | ASSERT(key != NULL); |