hikari.internal.cache#
Various utilities that may be used in a cache-impl.
Module Contents#
- hikari.internal.cache.DataT[source]#
Type-hint for “data” objects used for storing and building entities.
- class hikari.internal.cache.CacheMappingView(items) CacheMappingView(items, *, builder)[source]#
Bases:
hikari.api.cache.CacheView
[KeyT
,ValueT
]A cache mapping view implementation used for representing cached data.
- Parameters
- items
typing.Union
[typing.Mapping
[KeyT
,ValueT
],typing.Mapping
[KeyT
,DataT
]] A mapping of keys to the values in their raw forms, wrapped by a ref wrapper or in a data form.
- builder
typing.Optional
[typing.Callable
[[DataT
],ValueT
]] The callable used to build entities before they’re returned by the mapping. This is used to cover the case when items stores
DataT
objects.
- items
- class hikari.internal.cache.EmptyCacheView[source]#
Bases:
hikari.api.cache.CacheView
[Any
,Any
]An empty cache view implementation.
- class hikari.internal.cache.GuildRecord[source]#
An object used for storing guild specific cached information in-memory.
This includes references to the cached entities that “belong” to the guild by ID if it’s globally unique or by object if it’s only unique within the guild.
- is_available: Optional[bool][source]#
Whether the cached guild is available or not.
This will be
None
when noGuildRecord.guild
is alsoNone
elsebool
.
- guild: Optional[hikari.guilds.GatewayGuild][source]#
A cached guild object.
This will be
hikari.guilds.GatewayGuild
orNone
if not cached.
- channels: Optional[MutableSet[hikari.snowflakes.Snowflake]][source]#
A set of the IDs of the guild channels cached for this guild.
This will be
None
if no channels are cached for this guild elsetyping.MutableSet[hikari.snowflakes.Snowflake]
of channel IDs.
- threads: Optional[MutableSet[hikari.snowflakes.Snowflake]][source]#
A set of the IDs of the guild threads cached for this guild.
This will be
builtins.None
if no threads are cached for this guild elsetyping.MutableSet[hikari.snowflakes.Snowflake]
of thread IDs.
- emojis: Optional[MutableSet[hikari.snowflakes.Snowflake]][source]#
A set of the IDs of the emojis cached for this guild.
This will be
None
if no emojis are cached for this guild elsetyping.MutableSet[hikari.snowflakes.Snowflake]
of emoji IDs.
- stickers: Optional[MutableSet[hikari.snowflakes.Snowflake]][source]#
A sequence of sticker IDs cached for this guild.
This will be
None
if no stickers are cached for this guild elsetyping.Sequence[hikari.snowflakes.Snowflake]
of emoji IDs.
- invites: Optional[MutableSequence[str]][source]#
A set of the
str
codes of the invites cached for this guild.This will be
None
if no invites are cached for this guild elsetyping.MutableSequence[str]
of invite codes.
- members: Optional[hikari.internal.collections.ExtendedMutableMapping[hikari.snowflakes.Snowflake, RefCell[MemberData]]][source]#
A mapping of user IDs to the objects of members cached for this guild.
This will be
None
if no members are cached for this guild elsehikari.internal.collections.ExtendedMutableMapping[hikari.snowflakes.Snowflake, MemberData]
.
- presences: Optional[hikari.internal.collections.ExtendedMutableMapping[hikari.snowflakes.Snowflake, MemberPresenceData]][source]#
A mapping of user IDs to objects of the presences cached for this guild.
This will be
None
if no presences are cached for this guild elsehikari.internal.collections.ExtendedMutableMapping[hikari.snowflakes.Snowflake, MemberPresenceData]
.
- roles: Optional[MutableSet[hikari.snowflakes.Snowflake]][source]#
A set of the IDs of the roles cached for this guild.
This will be
None
if no roles are cached for this guild elsetyping.MutableSet[hikari.snowflakes.Snowflake]
of role IDs.
- voice_states: Optional[hikari.internal.collections.ExtendedMutableMapping[hikari.snowflakes.Snowflake, VoiceStateData]][source]#
A mapping of user IDs to objects of the voice states cached for this guild.
This will be
None
if no voice states are cached for this guild elsehikari.internal.collections.ExtendedMutableMapping[hikari.snowflakes.Snowflake, VoiceStateData]
.
- class hikari.internal.cache.BaseData[source]#
Bases:
abc.ABC
,Generic
[ValueT
]A data class used for in-memory storage of entities in a more primitive form.
Note
This base implementation assumes that all the fields it’ll handle will be immutable and to handle mutable fields you’ll have to override build_entity and build_from_entity to explicitly copy them.
- abstract build_entity(app, /)[source]#
Build an entity object from this data object.
- Parameters
- app
hikari.traits.RESTAware
The hikari application the built object should be bound to.
- app
- Returns
ValueT
The initialised entity object.
- class hikari.internal.cache.InviteData[source]#
Bases:
BaseData
[hikari.invites.InviteWithMetadata
]A data model for storing invite data in an in-memory cache.
- class hikari.internal.cache.MemberData[source]#
Bases:
BaseData
[hikari.guilds.Member
]A data model for storing member data in an in-memory cache.
- class hikari.internal.cache.KnownCustomEmojiData[source]#
Bases:
BaseData
[hikari.emojis.KnownCustomEmoji
]A data model for storing known custom emoji data in an in-memory cache.
- class hikari.internal.cache.RichActivityData[source]#
Bases:
BaseData
[hikari.presences.RichActivity
]A data model for storing rich activity data in an in-memory cache.
- class hikari.internal.cache.MemberPresenceData[source]#
Bases:
BaseData
[hikari.presences.MemberPresence
]A data model for storing presence data in an in-memory cache.
- class hikari.internal.cache.MessageInteractionData[source]#
Bases:
BaseData
[hikari.messages.MessageInteraction
]A model for storing message interaction data.
- class hikari.internal.cache.MessageData[source]#
Bases:
BaseData
[hikari.messages.Message
]A model for storing message data in an in-memory cache.
- class hikari.internal.cache.VoiceStateData[source]#
Bases:
BaseData
[hikari.voices.VoiceState
]A data model for storing voice state data in an in-memory cache.
- class hikari.internal.cache.RefCell[source]#
Bases:
Generic
[ValueT
]Object used to track mutable references to a value in multiple places.
This is intended to enable reference counting for entities that are only kept alive by reference (e.g. the unknown emoji objects attached to presence activities and user objects) without the use of a “Data” object which lowers the time spent building these entities for the objects that reference them.
- hikari.internal.cache.copy_guild_channel(channel)[source]#
Logic for handling the copying of guild channel objects.
This exists account for the permission overwrite objects attached to guild channel objects which need to be copied themselves.
- class hikari.internal.cache.Cache3DMappingView(items) Cache3DMappingView(items, *, builder)[source]#
Bases:
CacheMappingView
[hikari.snowflakes.Snowflake
,hikari.api.cache.CacheView
[KeyT
,ValueT
]]A special case of the Mapping View which avoids copying the immutable values contained within it.