Documentation
¶
Index ¶
- func NewInCache(db chat.Store) chat.Store
- type Cache
- func (c *Cache) AddGroupMembers(ctx context.Context, chatID *commonpb.ChatId, userIDs []*commonpb.UserId) (bool, chat.RosterSummary, error)
- func (c *Cache) AdvanceLastMessage(ctx context.Context, chatID *commonpb.ChatId, messageID *messagingpb.MessageId, ...) (bool, []*commonpb.UserId, error)
- func (c *Cache) GetChatByID(ctx context.Context, chatID *commonpb.ChatId) (*chat.Chat, error)
- func (c *Cache) GetDmFeedPage(ctx context.Context, userID *commonpb.UserId, chatType chatpb.ChatType, ...) ([]*chat.Chat, error)
- func (c *Cache) GetGroupChatsForUser(ctx context.Context, userID *commonpb.UserId) ([]*chat.Chat, error)
- func (c *Cache) GetGroupChatsForUserByIDs(ctx context.Context, userID *commonpb.UserId, chatIDs []*commonpb.ChatId) ([]*chat.Chat, error)
- func (c *Cache) GetGroupMembershipsForUser(ctx context.Context, userID *commonpb.UserId) ([]chat.GroupMembership, error)
- func (c *Cache) GetGroupRosterSummaries(ctx context.Context, chatIDs []*commonpb.ChatId) (map[string]chat.RosterSummary, error)
- func (c *Cache) GetGroupRosterSummary(ctx context.Context, chatID *commonpb.ChatId) (chat.RosterSummary, error)
- func (c *Cache) GetGroupRules(ctx context.Context, chatID *commonpb.ChatId) (*chatpb.Rules, error)
- func (c *Cache) GetMembers(ctx context.Context, chatID *commonpb.ChatId) ([]*commonpb.UserId, error)
- func (c *Cache) IsMember(ctx context.Context, chatID *commonpb.ChatId, userID *commonpb.UserId) (bool, error)
- func (c *Cache) PutChat(ctx context.Context, ch *chat.Chat) error
- func (c *Cache) RemoveGroupMember(ctx context.Context, chatID *commonpb.ChatId, userID *commonpb.UserId) (bool, chat.RosterSummary, error)
- func (c *Cache) SetGroupPicture(ctx context.Context, chatID *commonpb.ChatId, blobID *blobpb.BlobId) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
Cache wraps a chat.Store, caching what is fixed at a chat's creation and so can never go stale: DM membership checks, a DM's member list, and a group's participation rules. A DM's membership never changes, so a confirmed DM member, and the DM's member pair, are safe to cache. Group membership is mutable — and can be mutated by other processes, which this cache can never observe — so group membership checks and member lists always defer to the backing store. The rest of the store is passed straight through.
func (*Cache) AddGroupMembers ¶ added in v1.26.0
func (*Cache) AdvanceLastMessage ¶
func (*Cache) GetChatByID ¶
func (*Cache) GetDmFeedPage ¶
func (*Cache) GetGroupChatsForUser ¶ added in v1.30.0
func (*Cache) GetGroupChatsForUserByIDs ¶ added in v1.30.0
func (*Cache) GetGroupMembershipsForUser ¶ added in v1.30.0
func (c *Cache) GetGroupMembershipsForUser(ctx context.Context, userID *commonpb.UserId) ([]chat.GroupMembership, error)
Never cached, for the same reason group IsMember checks are not: group membership is mutable from other processes.
func (*Cache) GetGroupRosterSummaries ¶ added in v1.30.0
func (*Cache) GetGroupRosterSummary ¶ added in v1.30.0
func (*Cache) GetGroupRules ¶ added in v1.30.0
GetGroupRules is cached, including the absence of rules (a nil result), so a group without any is read once too. Rules are fixed at creation (see chat.Store), so a cached entry is never stale: if rules ever become mutable, this needs invalidation on write. A cached entry is shared by every caller and must be treated as read-only. Errors — including ErrChatNotFound, since the group may be created later — are not cached.
func (*Cache) GetMembers ¶
func (c *Cache) GetMembers(ctx context.Context, chatID *commonpb.ChatId) ([]*commonpb.UserId, error)
GetMembers is cached for a DM: its member pair is fixed at creation, so a list once read is never stale. It is the read behind every DM broadcast (a message, a pointer advance, a reaction, typing), which otherwise costs a store read per event just to find the peer. A group's roster is mutable, so a group's list always defers to the backing store, as IsMember does. Errors — including ErrChatNotFound, since the DM may be created later — are not cached. The caller gets its own copy, so the cached list is never mutated through a result.