Documentation ¶
Index ¶
- Constants
- Variables
- type CachedVisibility
- type Caches
- func (c *Caches) Init()
- func (c *Caches) OnInvalidateAccount(account *gtsmodel.Account)
- func (c *Caches) OnInvalidateBlock(block *gtsmodel.Block)
- func (c *Caches) OnInvalidateEmojiCategory(category *gtsmodel.EmojiCategory)
- func (c *Caches) OnInvalidateFollow(follow *gtsmodel.Follow)
- func (c *Caches) OnInvalidateFollowRequest(followReq *gtsmodel.FollowRequest)
- func (c *Caches) OnInvalidateList(list *gtsmodel.List)
- func (c *Caches) OnInvalidateMedia(media *gtsmodel.MediaAttachment)
- func (c *Caches) OnInvalidatePoll(poll *gtsmodel.Poll)
- func (c *Caches) OnInvalidatePollVote(vote *gtsmodel.PollVote)
- func (c *Caches) OnInvalidateStatus(status *gtsmodel.Status)
- func (c *Caches) OnInvalidateStatusFave(fave *gtsmodel.StatusFave)
- func (c *Caches) OnInvalidateUser(user *gtsmodel.User)
- func (c *Caches) Start()
- func (c *Caches) Stop()
- func (c *Caches) Sweep(threshold float64)
- type GTSCaches
- type SliceCache
- type VisibilityCache
- type VisibilityType
Constants ¶
const ( // Possible cache visibility lookup types. VisibilityTypeAccount = VisibilityType('a') VisibilityTypeStatus = VisibilityType('s') VisibilityTypeHome = VisibilityType('h') VisibilityTypePublic = VisibilityType('p') )
Variables ¶
var SentinelError = errors.New("BUG: error should not be returned") //nolint:revive
SentinelError is an error that can be returned and checked against to indicate a non-permanent error return from a cache loader callback, e.g. a temporary situation that will soon be fixed.
Functions ¶
This section is empty.
Types ¶
type CachedVisibility ¶ added in v0.8.0
type CachedVisibility struct { // ItemID is the ID of the item in question (status / account). ItemID string // RequesterID is the ID of the requesting account for this visibility lookup. RequesterID string // Type is the visibility lookup type. Type VisibilityType // Value is the actual visibility value. Value bool }
CachedVisibility represents a cached visibility lookup value.
type Caches ¶ added in v0.7.0
type Caches struct { // GTS provides access to the collection of // gtsmodel object caches. (used by the database). GTS GTSCaches // AllowHeaderFilters provides access to // the allow []headerfilter.Filter cache. AllowHeaderFilters headerfilter.Cache // BlockHeaderFilters provides access to // the block []headerfilter.Filter cache. BlockHeaderFilters headerfilter.Cache // Visibility provides access to the item visibility // cache. (used by the visibility filter). Visibility VisibilityCache // contains filtered or unexported fields }
func (*Caches) Init ¶ added in v0.7.0
func (c *Caches) Init()
Init will (re)initialize both the GTS and AP cache collections. NOTE: the cache MUST NOT be in use anywhere, this is not thread-safe.
func (*Caches) OnInvalidateAccount ¶ added in v0.14.0
func (*Caches) OnInvalidateBlock ¶ added in v0.14.0
func (*Caches) OnInvalidateEmojiCategory ¶ added in v0.14.0
func (c *Caches) OnInvalidateEmojiCategory(category *gtsmodel.EmojiCategory)
func (*Caches) OnInvalidateFollow ¶ added in v0.14.0
func (*Caches) OnInvalidateFollowRequest ¶ added in v0.14.0
func (c *Caches) OnInvalidateFollowRequest(followReq *gtsmodel.FollowRequest)
func (*Caches) OnInvalidateList ¶ added in v0.14.0
func (*Caches) OnInvalidateMedia ¶ added in v0.14.0
func (c *Caches) OnInvalidateMedia(media *gtsmodel.MediaAttachment)
func (*Caches) OnInvalidatePoll ¶ added in v0.14.0
func (*Caches) OnInvalidatePollVote ¶ added in v0.14.0
func (*Caches) OnInvalidateStatus ¶ added in v0.14.0
func (*Caches) OnInvalidateStatusFave ¶ added in v0.14.0
func (c *Caches) OnInvalidateStatusFave(fave *gtsmodel.StatusFave)
func (*Caches) OnInvalidateUser ¶ added in v0.14.0
func (*Caches) Start ¶ added in v0.7.0
func (c *Caches) Start()
Start will start any caches that require a background routine, which usually means any kind of TTL caches.
func (*Caches) Stop ¶ added in v0.7.0
func (c *Caches) Stop()
Stop will stop any caches that require a background routine, which usually means any kind of TTL caches.
func (*Caches) Sweep ¶ added in v0.11.0
Sweep will sweep all the available caches to ensure none are above threshold percent full to their total capacity.
This helps with cache performance, as a full cache will require an eviction on every single write, which adds significant overhead to all cache writes.
type GTSCaches ¶ added in v0.7.0
type GTSCaches struct { // Account provides access to the gtsmodel Account database cache. Account structr.Cache[*gtsmodel.Account] // AccountNote provides access to the gtsmodel Note database cache. AccountNote structr.Cache[*gtsmodel.AccountNote] // TEMPORARY CACHE TO ALLEVIATE SLOW COUNT QUERIES, // (in time will be removed when these IDs are cached). AccountCounts *simple.Cache[string, struct { Statuses int Pinned int }] // Application provides access to the gtsmodel Application database cache. Application structr.Cache[*gtsmodel.Application] // Block provides access to the gtsmodel Block (account) database cache. Block structr.Cache[*gtsmodel.Block] // FollowIDs provides access to the block IDs database cache. BlockIDs *SliceCache[string] // BoostOfIDs provides access to the boost of IDs list database cache. BoostOfIDs *SliceCache[string] // DomainAllow provides access to the domain allow database cache. DomainAllow *domain.Cache // DomainBlock provides access to the domain block database cache. DomainBlock *domain.Cache // Emoji provides access to the gtsmodel Emoji database cache. Emoji structr.Cache[*gtsmodel.Emoji] // EmojiCategory provides access to the gtsmodel EmojiCategory database cache. EmojiCategory structr.Cache[*gtsmodel.EmojiCategory] // Follow provides access to the gtsmodel Follow database cache. Follow structr.Cache[*gtsmodel.Follow] // 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 FollowIDs *SliceCache[string] // FollowRequest provides access to the gtsmodel FollowRequest database cache. FollowRequest structr.Cache[*gtsmodel.FollowRequest] // 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 FollowRequestIDs *SliceCache[string] // Instance provides access to the gtsmodel Instance database cache. Instance structr.Cache[*gtsmodel.Instance] // InReplyToIDs provides access to the status in reply to IDs list database cache. InReplyToIDs *SliceCache[string] // List provides access to the gtsmodel List database cache. List structr.Cache[*gtsmodel.List] // ListEntry provides access to the gtsmodel ListEntry database cache. ListEntry structr.Cache[*gtsmodel.ListEntry] // Marker provides access to the gtsmodel Marker database cache. Marker structr.Cache[*gtsmodel.Marker] // Media provides access to the gtsmodel Media database cache. Media structr.Cache[*gtsmodel.MediaAttachment] // Mention provides access to the gtsmodel Mention database cache. Mention structr.Cache[*gtsmodel.Mention] // Notification provides access to the gtsmodel Notification database cache. Notification structr.Cache[*gtsmodel.Notification] // Poll provides access to the gtsmodel Poll database cache. Poll structr.Cache[*gtsmodel.Poll] // PollVote provides access to the gtsmodel PollVote database cache. PollVote structr.Cache[*gtsmodel.PollVote] // PollVoteIDs provides access to the poll vote IDs list database cache. PollVoteIDs *SliceCache[string] // Report provides access to the gtsmodel Report database cache. Report structr.Cache[*gtsmodel.Report] // Status provides access to the gtsmodel Status database cache. Status structr.Cache[*gtsmodel.Status] // StatusFave provides access to the gtsmodel StatusFave database cache. StatusFave structr.Cache[*gtsmodel.StatusFave] // StatusFaveIDs provides access to the status fave IDs list database cache. StatusFaveIDs *SliceCache[string] // Tag provides access to the gtsmodel Tag database cache. Tag structr.Cache[*gtsmodel.Tag] // Tombstone provides access to the gtsmodel Tombstone database cache. Tombstone structr.Cache[*gtsmodel.Tombstone] // ThreadMute provides access to the gtsmodel ThreadMute database cache. ThreadMute structr.Cache[*gtsmodel.ThreadMute] // User provides access to the gtsmodel User database cache. User structr.Cache[*gtsmodel.User] // Webfinger provides access to the webfinger URL cache. // TODO: move out of GTS caches since unrelated to DB. Webfinger *ttl.Cache[string, string] // TTL=24hr, sweep=5min }
type SliceCache ¶ added in v0.11.0
SliceCache wraps a simple.Cache to provide simple loader-callback functions for fetching + caching slices of objects (e.g. IDs).
type VisibilityCache ¶ added in v0.8.0
type VisibilityCache struct { structr.Cache[*CachedVisibility] }
type VisibilityType ¶ added in v0.8.0
type VisibilityType byte
VisibilityType represents a visibility lookup type. We use a byte type here to improve performance in the result cache when generating the key.