mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-12-31 00:16:14 -06:00
add more cache invalidation explanatory comments
This commit is contained in:
parent
830893d713
commit
90bf3a1bbd
2 changed files with 72 additions and 17 deletions
53
internal/cache/db.go
vendored
53
internal/cache/db.go
vendored
|
|
@ -85,10 +85,23 @@ type DBCaches struct {
|
|||
|
||||
// FollowIDs provides access to the follower / following IDs database cache.
|
||||
// THIS CACHE IS KEYED AS THE FOLLOWING {prefix}{accountID} WHERE PREFIX IS:
|
||||
// - '>' for following IDs
|
||||
// - 'l>' for local following IDs
|
||||
// - '<' for follower IDs
|
||||
// - 'l<' for local follower IDs
|
||||
//
|
||||
// - '>{$accountID}' for following IDs
|
||||
// e.g. FollowIDs.Load(">" + account.ID, func() {})
|
||||
// which will load a slice of follows IDs FROM account.
|
||||
//
|
||||
// - 'l>{$accountID}' for local following IDs
|
||||
// e.g. FollowIDs.Load("l>" + account.ID, func() {})
|
||||
// which will load a slice of LOCAL follows IDs FROM account.
|
||||
//
|
||||
// - '<{$accountID}' for follower IDs
|
||||
// e.g. FollowIDs.Load("<" + account.ID, func() {})
|
||||
// which will load a slice of follows IDs TARGETTING account.
|
||||
//
|
||||
// - 'l<{$accountID}' for local follower IDs
|
||||
// e.g. FollowIDs.Load("l<" + account.ID, func() {})
|
||||
// which will load a slice of LOCAL follows IDs TARGETTING account.
|
||||
//
|
||||
FollowIDs SliceCache[string]
|
||||
|
||||
// FollowRequest provides access to the gtsmodel FollowRequest database cache.
|
||||
|
|
@ -96,14 +109,28 @@ type DBCaches struct {
|
|||
|
||||
// FollowRequestIDs provides access to the follow requester / requesting IDs database
|
||||
// cache. THIS CACHE IS KEYED AS THE FOLLOWING {prefix}{accountID} WHERE PREFIX IS:
|
||||
// - '>' for following IDs
|
||||
// - '<' for follower IDs
|
||||
//
|
||||
// - '>{$accountID}' for follow request IDs
|
||||
// e.g. FollowRequestIDs.Load(">" + account.ID, func() {})
|
||||
// which will load a slice of follow request IDs TARGETTING account.
|
||||
//
|
||||
// - '<{$accountID}' for follow request IDs
|
||||
// e.g. FollowRequestIDs.Load("<" + account.ID, func() {})
|
||||
// which will load a slice of follow request IDs FROM account.
|
||||
//
|
||||
FollowRequestIDs SliceCache[string]
|
||||
|
||||
// FollowingTagIDs provides access to account IDs following / tag IDs followed by
|
||||
// account db cache. THIS CACHE IS KEYED AS THE FOLLOWING {prefix}{id} WHERE:
|
||||
//
|
||||
// - '>{$accountID}' for tag IDs followed by account
|
||||
// e.g. FollowingTagIDs.Load(">" + account.ID, func() {})
|
||||
// which will load a slice of tag IDs followed by account.
|
||||
//
|
||||
// - '<{$tagIDs}' for account IDs following tag
|
||||
// e.g. FollowingTagIDs.Load("<" + tag.ID, func() {})
|
||||
// which will load a slice of account IDs following tag.
|
||||
//
|
||||
FollowingTagIDs SliceCache[string]
|
||||
|
||||
// Instance provides access to the gtsmodel Instance database cache.
|
||||
|
|
@ -120,14 +147,28 @@ type DBCaches struct {
|
|||
|
||||
// ListIDs provides access to the list IDs owned by account / list IDs follow
|
||||
// contained in db cache. THIS CACHE IS KEYED AS FOLLOWING {prefix}{id} WHERE:
|
||||
//
|
||||
// - 'a{$accountID}' for list IDs owned by account
|
||||
// e.g. ListIDs.Load("a" + account.ID, func() {})
|
||||
// which will load a slice of list IDs owned by account.
|
||||
//
|
||||
// - 'f{$followID}' for list IDs follow contained in
|
||||
// e.g. ListIDs.Load("f" + follow.ID, func() {})
|
||||
// which will load a slice of list IDs containing follow.
|
||||
//
|
||||
ListIDs SliceCache[string]
|
||||
|
||||
// ListedIDs provides access to the account IDs in list / follow IDs in
|
||||
// list db cache. THIS CACHE IS KEYED AS FOLLOWING {prefix}{id} WHERE:
|
||||
//
|
||||
// - 'a{listID}' for account IDs in list ID
|
||||
// e.g. ListedIDs.Load("a" + list.ID, func() {})
|
||||
// which will load a slice of account IDs in list.
|
||||
//
|
||||
// - 'f{listID}' for follow IDs in list ID
|
||||
// e.g. ListedIDs.Load("f" + list.ID, func() {})
|
||||
// which will load a slice of follow IDs in list.
|
||||
//
|
||||
ListedIDs SliceCache[string]
|
||||
|
||||
// Marker provides access to the gtsmodel Marker database cache.
|
||||
|
|
|
|||
36
internal/cache/invalidate.go
vendored
36
internal/cache/invalidate.go
vendored
|
|
@ -109,28 +109,28 @@ func (c *Caches) OnInvalidateFollow(follow *gtsmodel.Follow) {
|
|||
c.DB.FollowIDs.Invalidate(
|
||||
|
||||
// Invalidate follow ID lists
|
||||
// FROM the origin account
|
||||
// TARGETTING origin account
|
||||
// (including local-only follows).
|
||||
">"+follow.AccountID,
|
||||
"l>"+follow.AccountID,
|
||||
|
||||
// Invalidate follow ID lists
|
||||
// TARGETTING origin account
|
||||
// FROM the origin account
|
||||
// (including local-only follows).
|
||||
"<"+follow.AccountID,
|
||||
"l<"+follow.AccountID,
|
||||
|
||||
// Invalidate follow ID lists
|
||||
// FROM the target account
|
||||
// (including local-only follows).
|
||||
"<"+follow.TargetAccountID,
|
||||
"l<"+follow.TargetAccountID,
|
||||
|
||||
// Invalidate follow ID lists
|
||||
// TARGETTING the target account
|
||||
// (including local-only follows).
|
||||
">"+follow.TargetAccountID,
|
||||
"l>"+follow.TargetAccountID,
|
||||
|
||||
// Invalidate follow ID lists
|
||||
// FROM the target account
|
||||
// (including local-only follows).
|
||||
"<"+follow.TargetAccountID,
|
||||
"l<"+follow.TargetAccountID,
|
||||
)
|
||||
|
||||
// Invalidate ID slice cache.
|
||||
|
|
@ -153,13 +153,27 @@ func (c *Caches) OnInvalidateFollowRequest(followReq *gtsmodel.FollowRequest) {
|
|||
// Invalidate follow with this same ID.
|
||||
c.DB.Follow.Invalidate("ID", followReq.ID)
|
||||
|
||||
// Invalidate source account's followreq
|
||||
// lists, and destinations follow req lists.
|
||||
// (see FollowRequestIDs() comment for details).
|
||||
// Invalidate ID slice cache.
|
||||
c.DB.FollowRequestIDs.Invalidate(
|
||||
|
||||
// Invalidate follow request ID
|
||||
// lists TARGETTING origin account
|
||||
// (including local-only follows).
|
||||
">"+followReq.AccountID,
|
||||
|
||||
// Invalidate follow request ID
|
||||
// lists FROM the origin account
|
||||
// (including local-only follows).
|
||||
"<"+followReq.AccountID,
|
||||
|
||||
// Invalidate follow request ID
|
||||
// lists TARGETTING target account
|
||||
// (including local-only follows).
|
||||
">"+followReq.TargetAccountID,
|
||||
|
||||
// Invalidate follow request ID
|
||||
// lists FROM the target account
|
||||
// (including local-only follows).
|
||||
"<"+followReq.TargetAccountID,
|
||||
)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue