本文整理汇总了C++中cache_t::erase方法的典型用法代码示例。如果您正苦于以下问题:C++ cache_t::erase方法的具体用法?C++ cache_t::erase怎么用?C++ cache_t::erase使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cache_t
的用法示例。
在下文中一共展示了cache_t::erase方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: eraseExpired
void eraseExpired()
{
F64 now = LLFrameTimer::getTotalSeconds();
cache_t::iterator it = sCache.begin();
while (it != sCache.end())
{
cache_t::iterator cur = it;
LLSD& exp = cur->second;
++it;
if(exp.has(EXPIRES) && exp[EXPIRES].asReal() < now)
{
if(!exp.has(EXPERIENCE_ID))
{
LL_WARNS("ExperienceCache") << "Removing experience with no id " << LL_ENDL ;
sCache.erase(cur);
}
else
{
LLUUID id = exp[EXPERIENCE_ID].asUUID();
LLUUID private_key = exp.has(LLExperienceCache::PRIVATE_KEY) ? exp[LLExperienceCache::PRIVATE_KEY].asUUID():LLUUID::null;
if(private_key.notNull() || !exp.has("DoesNotExist"))
{
fetch(id, true);
}
else
{
LL_WARNS("ExperienceCache") << "Removing invalid experience " << id << LL_ENDL ;
sCache.erase(cur);
}
}
}
}
}
示例2: new_keys
typename std::enable_if<(sizeof...(Args), std::is_same<cache_t, cache_vector_t>::value) && tp == timeout_policy_t::NEVER, std::remove_const_t<std::decay_t<R>>>::type
const& call(Args const&... args)
{
decayed_key_t new_keys(getKey(args)...);
auto&& it(cache.find(new_keys));
if (it == cache.end()) // not cached
{
if (cache.size() == LRU_MAX) // cache is full, time to overwrite old objects
{
if (internal_it == internal_cache.end())
{
assert(cache_it == cache.end());
internal_it = internal_cache.begin();
cache_it = cache.begin();
}
*internal_it = fptr(args...);
cache.erase(cache_it);
cache.insert(cache_it, std::pair<key_t, internal_cache_it_t>(new_keys, internal_it));
++cache_it;
return *internal_it++;
}
else
{
// Maybe emplace_back
internal_cache.push_back(fptr(args...));
cache[new_keys] = internal_cache.end();
return internal_cache.back();
}
}
else // was cached
return *it->second;
};
示例3: erase
void erase( const LLUUID& key )
{
cache_t::iterator it = sCache.find(key);
if(it != sCache.end())
{
sCache.erase(it);
}
}