cache

package
v0.13.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 6, 2024 License: AGPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Possible cache visibility lookup types.
	VisibilityTypeAccount = VisibilityType('a')
	VisibilityTypeStatus  = VisibilityType('s')
	VisibilityTypeHome    = VisibilityType('h')
	VisibilityTypePublic  = VisibilityType('p')
)

Variables

View Source
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 APCaches added in v0.7.0

type APCaches struct{}

func (*APCaches) Init added in v0.7.0

func (c *APCaches) Init()

Init will initialize all the ActivityPub caches in this collection. NOTE: the cache MUST NOT be in use anywhere, this is not thread-safe.

func (*APCaches) Start added in v0.7.0

func (c *APCaches) Start()

Start will attempt to start all of the ActivityPub caches, or panic.

func (*APCaches) Stop added in v0.7.0

func (c *APCaches) Stop()

Stop will attempt to stop all of the ActivityPub caches, or panic.

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

	// AP provides access to the collection of ActivityPub object caches.
	// (planned to be used by the typeconverter).
	AP APCaches

	// 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) Start added in v0.7.0

func (c *Caches) Start()

Start will start both the GTS and AP cache collections.

func (*Caches) Stop added in v0.7.0

func (c *Caches) Stop()

Stop will stop both the GTS and AP cache collections.

func (*Caches) Sweep added in v0.11.0

func (c *Caches) Sweep(threshold float64)

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 {
	// contains filtered or unexported fields
}

func (*GTSCaches) Account added in v0.7.0

func (c *GTSCaches) Account() *result.Cache[*gtsmodel.Account]

Account provides access to the gtsmodel Account database cache.

func (*GTSCaches) AccountNote added in v0.11.0

func (c *GTSCaches) AccountNote() *result.Cache[*gtsmodel.AccountNote]

AccountNote provides access to the gtsmodel Note database cache.

func (*GTSCaches) Application added in v0.11.0

func (c *GTSCaches) Application() *result.Cache[*gtsmodel.Application]

Application provides access to the gtsmodel Application database cache.

func (*GTSCaches) Block added in v0.7.0

func (c *GTSCaches) Block() *result.Cache[*gtsmodel.Block]

Block provides access to the gtsmodel Block (account) database cache.

func (*GTSCaches) BlockIDs added in v0.11.0

func (c *GTSCaches) BlockIDs() *SliceCache[string]

FollowIDs provides access to the block IDs database cache.

func (*GTSCaches) BoostOfIDs added in v0.11.0

func (c *GTSCaches) BoostOfIDs() *SliceCache[string]

BoostOfIDs provides access to the boost of IDs list database cache.

func (*GTSCaches) DomainAllow added in v0.12.0

func (c *GTSCaches) DomainAllow() *domain.Cache

DomainAllow provides access to the domain allow database cache.

func (*GTSCaches) DomainBlock added in v0.7.0

func (c *GTSCaches) DomainBlock() *domain.Cache

DomainBlock provides access to the domain block database cache.

func (*GTSCaches) Emoji added in v0.7.0

func (c *GTSCaches) Emoji() *result.Cache[*gtsmodel.Emoji]

Emoji provides access to the gtsmodel Emoji database cache.

func (*GTSCaches) EmojiCategory added in v0.7.0

func (c *GTSCaches) EmojiCategory() *result.Cache[*gtsmodel.EmojiCategory]

EmojiCategory provides access to the gtsmodel EmojiCategory database cache.

func (*GTSCaches) Follow added in v0.8.0

func (c *GTSCaches) Follow() *result.Cache[*gtsmodel.Follow]

Follow provides access to the gtsmodel Follow database cache.

func (*GTSCaches) FollowIDs added in v0.11.0

func (c *GTSCaches) FollowIDs() *SliceCache[string]

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

func (*GTSCaches) FollowRequest added in v0.8.0

func (c *GTSCaches) FollowRequest() *result.Cache[*gtsmodel.FollowRequest]

FollowRequest provides access to the gtsmodel FollowRequest database cache.

func (*GTSCaches) FollowRequestIDs added in v0.11.0

func (c *GTSCaches) FollowRequestIDs() *SliceCache[string]

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

func (*GTSCaches) InReplyToIDs added in v0.11.0

func (c *GTSCaches) InReplyToIDs() *SliceCache[string]

InReplyToIDs provides access to the status in reply to IDs list database cache.

func (*GTSCaches) Init added in v0.7.0

func (c *GTSCaches) Init()

Init will initialize all the gtsmodel caches in this collection. NOTE: the cache MUST NOT be in use anywhere, this is not thread-safe.

func (*GTSCaches) Instance added in v0.10.0

func (c *GTSCaches) Instance() *result.Cache[*gtsmodel.Instance]

Instance provides access to the gtsmodel Instance database cache.

func (*GTSCaches) List added in v0.10.0

func (c *GTSCaches) List() *result.Cache[*gtsmodel.List]

List provides access to the gtsmodel List database cache.

func (*GTSCaches) ListEntry added in v0.10.0

func (c *GTSCaches) ListEntry() *result.Cache[*gtsmodel.ListEntry]

ListEntry provides access to the gtsmodel ListEntry database cache.

func (*GTSCaches) Marker added in v0.11.0

func (c *GTSCaches) Marker() *result.Cache[*gtsmodel.Marker]

Marker provides access to the gtsmodel Marker database cache.

func (*GTSCaches) Media added in v0.8.0

Media provides access to the gtsmodel Media database cache.

func (*GTSCaches) Mention added in v0.7.0

func (c *GTSCaches) Mention() *result.Cache[*gtsmodel.Mention]

Mention provides access to the gtsmodel Mention database cache.

func (*GTSCaches) Notification added in v0.7.0

func (c *GTSCaches) Notification() *result.Cache[*gtsmodel.Notification]

Notification provides access to the gtsmodel Notification database cache.

func (*GTSCaches) Poll added in v0.13.0

func (c *GTSCaches) Poll() *result.Cache[*gtsmodel.Poll]

Poll provides access to the gtsmodel Poll database cache.

func (*GTSCaches) PollVote added in v0.13.0

func (c *GTSCaches) PollVote() *result.Cache[*gtsmodel.PollVote]

PollVote provides access to the gtsmodel PollVote database cache.

func (*GTSCaches) PollVoteIDs added in v0.13.0

func (c *GTSCaches) PollVoteIDs() *SliceCache[string]

PollVoteIDs provides access to the poll vote IDs list database cache.

func (*GTSCaches) Report added in v0.7.0

func (c *GTSCaches) Report() *result.Cache[*gtsmodel.Report]

Report provides access to the gtsmodel Report database cache.

func (*GTSCaches) Start added in v0.7.0

func (c *GTSCaches) Start()

Start will attempt to start all of the gtsmodel caches, or panic.

func (*GTSCaches) Status added in v0.7.0

func (c *GTSCaches) Status() *result.Cache[*gtsmodel.Status]

Status provides access to the gtsmodel Status database cache.

func (*GTSCaches) StatusFave added in v0.8.0

func (c *GTSCaches) StatusFave() *result.Cache[*gtsmodel.StatusFave]

StatusFave provides access to the gtsmodel StatusFave database cache.

func (*GTSCaches) StatusFaveIDs added in v0.11.0

func (c *GTSCaches) StatusFaveIDs() *SliceCache[string]

StatusFaveIDs provides access to the status fave IDs list database cache.

func (*GTSCaches) Stop added in v0.7.0

func (c *GTSCaches) Stop()

Stop will attempt to stop all of the gtsmodel caches, or panic.

func (*GTSCaches) Tag added in v0.11.0

func (c *GTSCaches) Tag() *result.Cache[*gtsmodel.Tag]

Tag provides access to the gtsmodel Tag database cache.

func (*GTSCaches) ThreadMute added in v0.13.0

func (c *GTSCaches) ThreadMute() *result.Cache[*gtsmodel.ThreadMute]

ThreadMute provides access to the gtsmodel ThreadMute database cache.

func (*GTSCaches) Tombstone added in v0.7.0

func (c *GTSCaches) Tombstone() *result.Cache[*gtsmodel.Tombstone]

Tombstone provides access to the gtsmodel Tombstone database cache.

func (*GTSCaches) User added in v0.7.0

func (c *GTSCaches) User() *result.Cache[*gtsmodel.User]

User provides access to the gtsmodel User database cache.

func (*GTSCaches) Webfinger added in v0.8.0

func (c *GTSCaches) Webfinger() *ttl.Cache[string, string]

Webfinger provides access to the webfinger URL cache.

type SliceCache added in v0.11.0

type SliceCache[T any] struct {
	*simple.Cache[string, []T]
}

SliceCache wraps a simple.Cache to provide simple loader-callback functions for fetching + caching slices of objects (e.g. IDs).

func (*SliceCache[T]) Load added in v0.11.0

func (c *SliceCache[T]) Load(key string, load func() ([]T, error)) ([]T, error)

Load will attempt to load an existing slice from the cache for the given key, else calling the provided load function and caching the result.

type VisibilityCache added in v0.8.0

type VisibilityCache struct {
	*result.Cache[*CachedVisibility]
}

func (*VisibilityCache) Init added in v0.8.0

func (c *VisibilityCache) Init()

Init will initialize the visibility cache in this collection. NOTE: the cache MUST NOT be in use anywhere, this is not thread-safe.

func (*VisibilityCache) Start added in v0.8.0

func (c *VisibilityCache) Start()

Start will attempt to start the visibility cache, or panic.

func (*VisibilityCache) Stop added in v0.8.0

func (c *VisibilityCache) Stop()

Stop will attempt to stop the visibility cache, or panic.

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.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL