mirror of https://gitee.com/bigwinds/arangodb
Updated plain cache to properly count evictions.
This commit is contained in:
parent
99d8180d94
commit
a4aa1eedd2
|
@ -42,7 +42,7 @@ using namespace arangodb::cache;
|
||||||
|
|
||||||
Finding PlainCache::find(void const* key, uint32_t keySize) {
|
Finding PlainCache::find(void const* key, uint32_t keySize) {
|
||||||
TRI_ASSERT(key != nullptr);
|
TRI_ASSERT(key != nullptr);
|
||||||
Finding result(nullptr);
|
Finding result;
|
||||||
uint32_t hash = hashKey(key, keySize);
|
uint32_t hash = hashKey(key, keySize);
|
||||||
|
|
||||||
bool ok;
|
bool ok;
|
||||||
|
@ -51,7 +51,7 @@ Finding PlainCache::find(void const* key, uint32_t keySize) {
|
||||||
std::tie(ok, bucket, source) = getBucket(hash, Cache::triesFast);
|
std::tie(ok, bucket, source) = getBucket(hash, Cache::triesFast);
|
||||||
|
|
||||||
if (ok) {
|
if (ok) {
|
||||||
result.reset(bucket->find(hash, key, keySize));
|
result.set(bucket->find(hash, key, keySize));
|
||||||
recordStat(result.found() ? Stat::findHit : Stat::findMiss);
|
recordStat(result.found() ? Stat::findHit : Stat::findMiss);
|
||||||
bucket->unlock();
|
bucket->unlock();
|
||||||
endOperation();
|
endOperation();
|
||||||
|
@ -96,8 +96,10 @@ bool PlainCache::insert(CachedValue* value) {
|
||||||
bool eviction = false;
|
bool eviction = false;
|
||||||
if (candidate != nullptr) {
|
if (candidate != nullptr) {
|
||||||
bucket->evict(candidate, true);
|
bucket->evict(candidate, true);
|
||||||
|
if (!candidate->sameKey(value->key(), value->keySize)) {
|
||||||
|
eviction = true;
|
||||||
|
}
|
||||||
freeValue(candidate);
|
freeValue(candidate);
|
||||||
eviction = true;
|
|
||||||
}
|
}
|
||||||
bucket->insert(hash, value);
|
bucket->insert(hash, value);
|
||||||
inserted = true;
|
inserted = true;
|
||||||
|
|
Loading…
Reference in New Issue