Skip to content

~.base

Backend

Bases: ABC

Base persistent cache backend.

bulk_channels abstractmethod async

bulk_channels(
    channels: Iterable[hikari.GuildChannel],
    confirm: Literal[False],
) -> None
bulk_channels(
    channels: Iterable[hikari.GuildChannel],
    confirm: Literal[True],
) -> asyncio.Future[None]
bulk_channels(
    channels: Sequence[hikari.GuildChannel], confirm: bool
) -> asyncio.Future[None] | None

Insert or update channels in bulk.

PARAMETER DESCRIPTION
channels

The channels to insert or update.

TYPE: Sequence[hikari.GuildChannel]

confirm

If True, this method will wait until the database transaction containing this operation has been committed before returning. If False, the operation is queued and this method returns immediately.

TYPE: bool

RETURNS DESCRIPTION
asyncio.Future[None] | None

If confirm, the returned future to wait for.

bulk_members abstractmethod async

bulk_members(
    members: Iterable[hikari.Member],
    confirm: Literal[False],
) -> None
bulk_members(
    members: Iterable[hikari.Member], confirm: Literal[True]
) -> asyncio.Future[None]
bulk_members(
    members: Iterable[hikari.Member], confirm: bool
) -> asyncio.Future[None] | None

Insert or update members in bulk.

PARAMETER DESCRIPTION
members

The members to insert or update.

TYPE: Iterable[hikari.Member]

confirm

If True, this method will wait until the database transaction containing this operation has been committed before returning. If False, the operation is queued and this method returns immediately.

TYPE: bool

RETURNS DESCRIPTION
asyncio.Future[None] | None

If confirm, the returned future to wait for.

bulk_roles abstractmethod async

bulk_roles(
    roles: Iterable[hikari.Role], confirm: Literal[False]
) -> None
bulk_roles(
    roles: Iterable[hikari.Role], confirm: Literal[True]
) -> asyncio.Future[None]
bulk_roles(
    roles: Iterable[hikari.Role], confirm: bool
) -> asyncio.Future[None] | None

Insert or update roles in bulk.

PARAMETER DESCRIPTION
roles

The roles to insert or update.

TYPE: Iterable[hikari.Role]

confirm

If True, this method will wait until the database transaction containing this operation has been committed before returning. If False, the operation is queued and this method returns immediately.

TYPE: bool

RETURNS DESCRIPTION
asyncio.Future[None] | None

If confirm, the returned future to wait for.

channel_create abstractmethod async

channel_create(
    channel: hikari.GuildChannel, confirm: Literal[False]
) -> None
channel_create(
    channel: hikari.GuildChannel, confirm: Literal[True]
) -> asyncio.Future[None]
channel_create(
    channel: hikari.GuildChannel, confirm: bool
) -> asyncio.Future[None] | None

Store a created channel.

PARAMETER DESCRIPTION
channel

The created channel to store.

TYPE: hikari.GuildChannel

confirm

If True, this method will wait until the database transaction containing this operation has been committed before returning. If False, the operation is queued and this method returns immediately.

TYPE: bool

RETURNS DESCRIPTION
asyncio.Future[None] | None

If confirm, the returned future to wait for.

channel_delete abstractmethod async

channel_delete(
    channel_id: hikari.Snowflake, confirm: Literal[False]
) -> None
channel_delete(
    channel_id: hikari.Snowflake, confirm: Literal[True]
) -> asyncio.Future[None]
channel_delete(
    channel_id: hikari.Snowflake, confirm: bool
) -> asyncio.Future[None] | None

Remove a deleted channel.

PARAMETER DESCRIPTION
channel_id

The ID of the channel that was deleted.

TYPE: hikari.Snowflake

confirm

If True, this method will wait until the database transaction containing this operation has been committed before returning. If False, the operation is queued and this method returns immediately.

TYPE: bool

RETURNS DESCRIPTION
asyncio.Future[None] | None

If confirm, the returned future to wait for.

channel_update abstractmethod async

channel_update(
    channel: hikari.GuildChannel, confirm: Literal[False]
) -> None
channel_update(
    channel: hikari.GuildChannel, confirm: Literal[True]
) -> asyncio.Future[None]
channel_update(
    channel: hikari.GuildChannel, confirm: bool
) -> asyncio.Future[None] | None

Update an updated channel.

PARAMETER DESCRIPTION
channel

The updated channel to update.

TYPE: hikari.GuildChannel

confirm

If True, this method will wait until the database transaction containing this operation has been committed before returning. If False, the operation is queued and this method returns immediately.

TYPE: bool

RETURNS DESCRIPTION
asyncio.Future[None] | None

If confirm, the returned future to wait for.

clear abstractmethod async

clear(
    channels: bool, guilds: bool, members: bool, roles: bool
) -> None

Clear select cache data.

PARAMETER DESCRIPTION
channels

If all channels should be cleared.

TYPE: bool

guilds

If all guilds should be cleared.

TYPE: bool

members

If all members should be cleared.

TYPE: bool

roles

If all roles should be cleared.

TYPE: bool

connect abstractmethod async

connect(*args: tuple, **kwargs: dict[str, Any]) -> None

Establish a connection with the backend database and initialize.

disconnect abstractmethod async

disconnect(*args: tuple, **kwargs: dict[str, Any]) -> None

Save state and disconnect from a backend database.

guild_join abstractmethod async

guild_join(
    guild: hikari.GatewayGuild, confirm: Literal[False]
) -> None
guild_join(
    guild: hikari.GatewayGuild, confirm: Literal[True]
) -> asyncio.Future[None]
guild_join(
    guild: hikari.GatewayGuild, confirm: bool
) -> asyncio.Future[None] | None

Store a joined guild.

PARAMETER DESCRIPTION
guild

The guild that was joined.

TYPE: hikari.GatewayGuild

confirm

If True, this method will wait until the database transaction containing this operation has been committed before returning. If False, the operation is queued and this method returns immediately.

TYPE: bool

RETURNS DESCRIPTION
asyncio.Future[None] | None

If confirm, the returned future to wait for.

guild_leave abstractmethod async

guild_leave(
    guild_id: hikari.Snowflake, confirm: Literal[False]
) -> None
guild_leave(
    guild_id: hikari.Snowflake, confirm: Literal[True]
) -> asyncio.Future[None]
guild_leave(
    guild_id: hikari.Snowflake, confirm: bool
) -> asyncio.Future[None] | None

Remove a left guild.

PARAMETER DESCRIPTION
guild_id

The ID of the guild that was left.

TYPE: hikari.Snowflake

confirm

If True, this method will wait until the database transaction containing this operation has been committed before returning. If False, the operation is queued and this method returns immediately.

TYPE: bool

RETURNS DESCRIPTION
asyncio.Future[None] | None

If confirm, the returned future to wait for.

guild_update abstractmethod async

guild_update(
    guild: hikari.GatewayGuild, confirm: Literal[False]
) -> None
guild_update(
    guild: hikari.GatewayGuild, confirm: Literal[True]
) -> asyncio.Future[None]
guild_update(
    guild: hikari.GatewayGuild, confirm: bool
) -> asyncio.Future[None] | None

Update an updated guild.

PARAMETER DESCRIPTION
guild

The updated guild to update.

TYPE: hikari.GatewayGuild

confirm

If True, this method will wait until the database transaction containing this operation has been committed before returning. If False, the operation is queued and this method returns immediately.

TYPE: bool

RETURNS DESCRIPTION
asyncio.Future[None] | None

If confirm, the returned future to wait for.

iter_channels abstractmethod async

iter_channels(
    query: ChannelQuery | None,
) -> AsyncIterator[hikari.GuildChannel]

Iterate through all channels in a query.

PARAMETER DESCRIPTION
query

If provided, the channel query used in cache lookup for filtration.

TYPE: ChannelQuery | None

RETURNS DESCRIPTION
AsyncIterator[hikari.GuildChannel]

The async iterator containing the queried channels.

iter_guilds abstractmethod async

iter_guilds(
    query: GuildQuery | None,
) -> AsyncIterator[hikari.Guild]

Iterate through all guilds in a query.

PARAMETER DESCRIPTION
query

If provided, the guild query used in cache lookup for filtration.

TYPE: GuildQuery | None

RETURNS DESCRIPTION
AsyncIterator[hikari.Guild]

The async iterator containing the queried guilds.

iter_members abstractmethod async

iter_members(
    query: MemberQuery | None,
) -> AsyncIterator[hikari.Member]

Iterate through all members in a query.

PARAMETER DESCRIPTION
query

If provided, the member query used in cache lookup for filtration.

TYPE: GuildQuery | None

RETURNS DESCRIPTION
AsyncIterator[hikari.Member]

The async iterator containing the queried members.

iter_roles abstractmethod async

iter_roles(
    query: RoleQuery | None,
) -> AsyncIterator[hikari.Role]

Iterate through all roles in a query.

PARAMETER DESCRIPTION
query

If provided, the role query used in cache lookup for filtration.

TYPE: RoleQuery | None

RETURNS DESCRIPTION
AsyncIterator[hikari.Role]

The async iterator containing the queried roles.

member_create abstractmethod async

member_create(
    member: hikari.Member, confirm: Literal[False]
) -> None
member_create(
    member: hikari.Member, confirm: Literal[True]
) -> asyncio.Future[None]
member_create(
    member: hikari.Member, confirm: bool
) -> asyncio.Future[None] | None

Store a created member.

PARAMETER DESCRIPTION
member

The created member to store.

TYPE: hikari.Member

confirm

If True, this method will wait until the database transaction containing this operation has been committed before returning. If False, the operation is queued and this method returns immediately.

TYPE: bool

RETURNS DESCRIPTION
asyncio.Future[None] | None

If confirm, the returned future to wait for.

member_delete abstractmethod async

member_delete(
    user_id: hikari.Snowflake,
    guild_id: hikari.Snowflake,
    confirm: Literal[False],
) -> None
member_delete(
    user_id: hikari.Snowflake,
    guild_id: hikari.Snowflake,
    confirm: Literal[True],
) -> asyncio.Future[None]
member_delete(
    user_id: hikari.Snowflake,
    guild_id: hikari.Snowflake,
    confirm: bool,
) -> asyncio.Future[None] | None

Remove a deleted member.

PARAMETER DESCRIPTION
user_id

The ID of the user that left/was deleted.

TYPE: hikari.Snowflake

guild_id

The ID of the guild that the user left.

TYPE: hikari.Snowflake

confirm

If True, this method will wait until the database transaction containing this operation has been committed before returning. If False, the operation is queued and this method returns immediately.

TYPE: bool

RETURNS DESCRIPTION
asyncio.Future[None] | None

If confirm, the returned future to wait for.

member_update abstractmethod async

member_update(
    member: hikari.Member, confirm: Literal[False]
) -> None
member_update(
    member: hikari.Member, confirm: Literal[True]
) -> asyncio.Future[None]
member_update(
    member: hikari.Member, confirm: bool
) -> asyncio.Future[None] | None

Update an updated member.

PARAMETER DESCRIPTION
member

The updated member to update.

TYPE: hikari.Member

confirm

If True, this method will wait until the database transaction containing this operation has been committed before returning. If False, the operation is queued and this method returns immediately.

TYPE: bool

RETURNS DESCRIPTION
asyncio.Future[None] | None

If confirm, the returned future to wait for.

prune abstractmethod async

prune() -> None

Prune all objects in cache that weren't updated on startup.

restore abstractmethod async

restore(path: Path) -> None

Restore the backend from a backed up file.

PARAMETER DESCRIPTION
path

The path to the file to restore.

TYPE: Path

role_create abstractmethod async

role_create(
    role: hikari.Role, confirm: Literal[False]
) -> None
role_create(
    role: hikari.Role, confirm: Literal[True]
) -> asyncio.Future[None]
role_create(
    role: hikari.Role, confirm: bool
) -> asyncio.Future[None] | None

Store a created role.

PARAMETER DESCRIPTION
role

The created role to store.

TYPE: hikari.Role

confirm

If True, this method will wait until the database transaction containing this operation has been committed before returning. If False, the operation is queued and this method returns immediately.

TYPE: bool

RETURNS DESCRIPTION
asyncio.Future[None] | None

If confirm, the returned future to wait for.

role_delete abstractmethod async

role_delete(
    role_id: hikari.Snowflake, confirm: Literal[False]
) -> None
role_delete(
    role_id: hikari.Snowflake, confirm: Literal[True]
) -> asyncio.Future[None]
role_delete(
    role_id: hikari.Snowflake, confirm: bool
) -> asyncio.Future[None] | None

Remove a deleted role.

PARAMETER DESCRIPTION
role_id

The ID of the role that was deleted.

TYPE: hikari.Snowflake

confirm

If True, this method will wait until the database transaction containing this operation has been committed before returning. If False, the operation is queued and this method returns immediately.

TYPE: bool

RETURNS DESCRIPTION
asyncio.Future[None] | None

If confirm, the returned future to wait for.

role_update abstractmethod async

role_update(
    role: hikari.Role, confirm: Literal[False]
) -> None
role_update(
    role: hikari.Role, confirm: Literal[True]
) -> asyncio.Future[None]
role_update(
    role: hikari.Role, confirm: bool
) -> asyncio.Future[None] | None

Update an updated role.

PARAMETER DESCRIPTION
role

The updated role to update.

TYPE: hikari.Role

confirm

If True, this method will wait until the database transaction containing this operation has been committed before returning. If False, the operation is queued and this method returns immediately.

TYPE: bool

RETURNS DESCRIPTION
asyncio.Future[None] | None

If confirm, the returned future to wait for.

snapshot abstractmethod async

snapshot(path: Path) -> None

Back up the backend into a restorable file.

PARAMETER DESCRIPTION
path

The path to the file to create as the backup.

TYPE: Path