Permalink
Browse files

value_cache: expire value if expiration is now

  • Loading branch information...
aberaud committed Aug 12, 2018
1 parent 57aba45 commit 246af2f06530882950de0beac9913153beb9ad75
Showing with 3 additions and 3 deletions.
  1. +3 −3 src/value_cache.h
View
@@ -66,15 +66,15 @@ class ValueCache {
CallbackQueue expireValues(const time_point& now, time_point& next) {
std::vector<Sp<Value>> expired_values;
for (auto it = values.begin(); it != values.end();) {
if (it->second.expiration < now) {
if (it->second.expiration <= now) {
expired_values.emplace_back(std::move(it->second.data));
it = values.erase(it);
} else {
next = std::min(next, it->second.expiration);
++it;
}
}
while (values.size() >= MAX_VALUES) {
while (values.size() > MAX_VALUES) {
// too many values, remove oldest values
time_point oldest_creation = time_point::max();
auto oldest_value = values.end();
@@ -127,7 +127,7 @@ class ValueCache {
ValueCache& operator=(ValueCache&&) = delete;
/* The maximum number of values we store in the cache. */
static constexpr unsigned MAX_VALUES {1024};
static constexpr unsigned MAX_VALUES {4096};
struct CacheValueStorage {
Sp<Value> data {};

0 comments on commit 246af2f

Please sign in to comment.