void ObjectCache::touch_lru(string& name, std::list<string>::iterator& lru_iter)
{
- while (lru.size() > (size_t)cct->_conf->rgw_cache_lru_size) {
+ while (lru_size > (size_t)cct->_conf->rgw_cache_lru_size) {
list<string>::iterator iter = lru.begin();
if ((*iter).compare(name) == 0) {
/*
if (map_iter != cache_map.end())
cache_map.erase(map_iter);
lru.pop_front();
+ lru_size--;
}
if (lru_iter == lru.end()) {
lru.push_back(name);
+ lru_size++;
lru_iter--;
ldout(cct, 10) << "adding " << name << " to cache LRU end" << dendl;
} else {
return;
lru.erase(lru_iter);
+ lru_size--;
lru_iter = lru.end();
}
class ObjectCache {
std::map<string, ObjectCacheEntry> cache_map;
std::list<string> lru;
+ unsigned long lru_size;
Mutex lock;
CephContext *cct;
void touch_lru(string& name, std::list<string>::iterator& lru_iter);
void remove_lru(string& name, std::list<string>::iterator& lru_iter);
public:
- ObjectCache() : lock("ObjectCache"), cct(NULL) { }
+ ObjectCache() : lru_size(0), lock("ObjectCache"), cct(NULL) { }
int get(std::string& name, ObjectCacheInfo& bl, uint32_t mask);
void put(std::string& name, ObjectCacheInfo& bl);
void remove(std::string& name);