mirror of
https://github.com/matrix-construct/construct
synced 2024-12-27 07:54:05 +01:00
ircd:Ⓜ️:room::state: Add prefetch() support to state::history/state::space.
This commit is contained in:
parent
6ed0db3274
commit
83cce03f6f
3 changed files with 57 additions and 0 deletions
|
@ -36,6 +36,9 @@ struct ircd::m::room::state::history
|
|||
event::idx get(std::nothrow_t, const string_view &type, const string_view &state_key) const;
|
||||
event::idx get(const string_view &type, const string_view &state_key) const;
|
||||
|
||||
bool prefetch(const string_view &type, const string_view &state_key) const;
|
||||
bool prefetch(const string_view &type) const;
|
||||
|
||||
history(const m::room &, const int64_t &bound);
|
||||
history(const m::room::id &, const m::event::id &);
|
||||
history(const m::room &);
|
||||
|
|
|
@ -39,6 +39,10 @@ struct ircd::m::room::state::space
|
|||
bool has(const string_view &type, const string_view &state_key) const;
|
||||
bool has(const string_view &type) const;
|
||||
|
||||
bool prefetch(const string_view &type, const string_view &state_key, const int64_t &depth) const;
|
||||
bool prefetch(const string_view &type, const string_view &state_key) const;
|
||||
bool prefetch(const string_view &type) const;
|
||||
|
||||
space(const m::room &);
|
||||
};
|
||||
|
||||
|
|
|
@ -2580,6 +2580,21 @@ ircd::m::room::state::history::history(const m::room &room,
|
|||
{
|
||||
}
|
||||
|
||||
bool
|
||||
ircd::m::room::state::history::prefetch(const string_view &type)
|
||||
const
|
||||
{
|
||||
return prefetch(type, string_view{});
|
||||
}
|
||||
|
||||
bool
|
||||
ircd::m::room::state::history::prefetch(const string_view &type,
|
||||
const string_view &state_key)
|
||||
const
|
||||
{
|
||||
return space.prefetch(type, state_key, bound);
|
||||
}
|
||||
|
||||
ircd::m::event::idx
|
||||
ircd::m::room::state::history::get(const string_view &type,
|
||||
const string_view &state_key)
|
||||
|
@ -2725,6 +2740,41 @@ ircd::m::room::state::space::space(const m::room &room)
|
|||
{
|
||||
}
|
||||
|
||||
bool
|
||||
ircd::m::room::state::space::prefetch(const string_view &type)
|
||||
const
|
||||
{
|
||||
return prefetch(type, string_view{});
|
||||
}
|
||||
|
||||
bool
|
||||
ircd::m::room::state::space::prefetch(const string_view &type,
|
||||
const string_view &state_key)
|
||||
const
|
||||
{
|
||||
return prefetch(type, state_key, -1);
|
||||
}
|
||||
|
||||
bool
|
||||
ircd::m::room::state::space::prefetch(const string_view &type,
|
||||
const string_view &state_key,
|
||||
const int64_t &depth)
|
||||
const
|
||||
{
|
||||
const int64_t &_depth
|
||||
{
|
||||
type? depth : 0L
|
||||
};
|
||||
|
||||
char buf[dbs::ROOM_STATE_SPACE_KEY_MAX_SIZE];
|
||||
const string_view &key
|
||||
{
|
||||
dbs::room_state_space_key(buf, room.room_id, type, state_key, _depth, 0UL)
|
||||
};
|
||||
|
||||
return db::prefetch(dbs::room_state_space, key);
|
||||
}
|
||||
|
||||
bool
|
||||
ircd::m::room::state::space::has(const string_view &type)
|
||||
const
|
||||
|
|
Loading…
Reference in a new issue