0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-12-26 15:33:54 +01:00

ircd:Ⓜ️:room::aliases: Improve aliases cache::get related.

This commit is contained in:
Jason Volk 2020-11-11 15:48:05 -08:00
parent 9bb50284c0
commit 4b60068809

View file

@ -222,39 +222,32 @@ ircd::m::room::aliases::cache::get(std::nothrow_t,
getidx(alias) getidx(alias)
}; };
if(!event_idx) const bool expired
{
!my_host(alias.host()) && (!event_idx || cache::expired(event_idx))
};
if(!event_idx || expired)
{ {
if(my_host(alias.host())) if(my_host(alias.host()))
return false; return false;
if(expired)
log::dwarning
{
log, "Cached alias %s expired age:%ld ttl:%ld",
string_view{alias},
cache::age(event_idx).count(),
milliseconds(seconds(alias_cache_ttl)).count(),
};
if(!fetch(std::nothrow, alias, alias.host())) if(!fetch(std::nothrow, alias, alias.host()))
return false; return false;
event_idx = getidx(alias); if(!(event_idx = getidx(alias)))
return false;
} }
const bool expired
{
!my_host(alias.host()) && cache::expired(event_idx)
};
if(expired)
{
log::dwarning
{
log, "Cached alias %s expired age:%ld ttl:%ld",
string_view{alias},
cache::age(event_idx).count(),
milliseconds(seconds(alias_cache_ttl)).count(),
};
fetch(std::nothrow, alias, alias.host());
event_idx = getidx(alias);
}
if(!event_idx)
return false;
bool ret{false}; bool ret{false};
m::get(std::nothrow, event_idx, "content", [&closure, &ret] m::get(std::nothrow, event_idx, "content", [&closure, &ret]
(const json::object &content) (const json::object &content)