diff --git a/util/flexcache.cc b/util/flexcache.cc index d225726d..46e966c5 100644 --- a/util/flexcache.cc +++ b/util/flexcache.cc @@ -75,22 +75,24 @@ FlexCache::GetDBCacheCapacity( bool IsInternal) //!< value describing cache attributes of caller { uint64_t ret_val, shared_total; - size_t user_count, internal_count, count; + size_t count, internal_count; // get count of database by type - user_count=DBList()->GetDBCount(false); - internal_count=DBList()->GetDBCount(true); + count=DBList()->GetDBCount(IsInternal); + if (IsInternal) + internal_count=count; + else + internal_count=DBList()->GetDBCount(true); // what is total memory assigned to a type - if (IsInternal && 0!=user_count) + if (IsInternal) shared_total=(m_TotalMemory*2)/10; // integer *.2 - else if (!IsInternal && 0!=internal_count) + else if (0!=internal_count) shared_total=(m_TotalMemory*8)/10; - else // no databases in "other" category + else // no internal database shared_total=m_TotalMemory; // split up type specific aggregate to "per database" value - count = (IsInternal ? internal_count : user_count); if (0!=count) ret_val=shared_total / count; else diff --git a/util/flexcache_test.cc b/util/flexcache_test.cc index 5554317f..a9fa8b42 100644 --- a/util/flexcache_test.cc +++ b/util/flexcache_test.cc @@ -179,10 +179,10 @@ TEST(FlexCacheTest, MixedSizing) { ASSERT_EQ(0, DBList()->GetDBCount(false)); ASSERT_EQ(1, DBList()->GetDBCount(true)); db[1]->GetProperty("leveldb.block-cache", &value); - ASSERT_EQ(552*1024*1024L, atoi(value.c_str())); + ASSERT_EQ(72*1024*1024L, atoi(value.c_str())); db[1]->GetProperty("leveldb.file-cache", &value); - ASSERT_EQ(550*1024*1024L, atoi(value.c_str())); + ASSERT_EQ(70*1024*1024L, atoi(value.c_str())); delete db[1];