0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-06-24 12:58:21 +02: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)
};
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()))
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()))
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};
m::get(std::nothrow, event_idx, "content", [&closure, &ret]
(const json::object &content)