value cache: keep track of expired values in case of edition

This commit is contained in:
Adrien Béraud committed 2026-02-22 18:45:17 -05:00
1 parent 6a45891ee7
commit b2ff05407b
1 file changed
+10
+10
View File
@@ -165,6 +165,7 @@ private:
CallbackQueue addValues(const std::vector<Sp<Value>>& new_values, const TypeStore& types, const time_point& now)
{
std::vector<Sp<Value>> nvals;
std::vector<Sp<Value>> 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;