diff --git a/src/value_cache.h b/src/value_cache.h index 730d95bd..cabb0731 100644 --- a/src/value_cache.h +++ b/src/value_cache.h @@ -165,6 +165,7 @@ private: CallbackQueue addValues(const std::vector>& new_values, const TypeStore& types, const time_point& now) { std::vector> nvals; + std::vector> expired_vals; for (const auto& value : new_values) { auto v = values.find(value->id); if (v == values.end()) { @@ -175,9 +176,18 @@ private: // refreshed value v->second.created = now; v->second.expiration = now + types.getType(v->second.data->type).expiration; + if (*v->second.data != *value) { + expired_vals.emplace_back(v->second.data); + v->second.data = value; + nvals.emplace_back(value); + } } } CallbackQueue ret; + if (callback and not expired_vals.empty()) + ret.emplace_back([cb = callback, expired_vals = std::move(expired_vals)]{ + cb(expired_vals, true); + }); if (callback and not nvals.empty()) ret.emplace_back([cb = callback, nvals = std::move(nvals)] { cb(nvals, false); }); return ret;