Skip to content

Commit

Permalink
Clamp active entries in LRU, not hash map.
Browse files Browse the repository at this point in the history
This is just a conceptual change, but helps to an extent with the
production of a combined disk and memory cache.
  • Loading branch information
caladri committed Mar 19, 2015
1 parent be1cd44 commit bea8f6f
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion xcodec/xcodec_cache.h
Expand Up @@ -144,6 +144,11 @@ class XCodecCacheLRU {
~XCodecCacheLRU()
{ }

size_t active(void) const
{
return (segment_lru_map_.size());
}

uint64_t enter(uint64_t hash)
{
uint64_t counter = ++segment_lru_counter_;
Expand Down Expand Up @@ -252,7 +257,7 @@ class XCodecMemoryCache : public XCodecCache {
void enter(const uint64_t& hash, BufferSegment *seg)
{
if (memory_cache_limit_ != 0 &&
segment_hash_map_.size() == memory_cache_limit_) {
segment_lru_.active() == memory_cache_limit_) {
/*
* Find the oldest hash.
*/
Expand Down

0 comments on commit bea8f6f

Please sign in to comment.