cache

package
v0.3.5 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2022 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = errors.New("value not found in cache")

ErrNotFound means that a value for the requested key was not found in the cache.

Functions

This section is empty.

Types

type AccountCache

type AccountCache struct {
	// contains filtered or unexported fields
}

AccountCache is a wrapper around ttlcache.Cache to provide URL and URI lookups for gtsmodel.Account

func NewAccountCache

func NewAccountCache() *AccountCache

NewAccountCache returns a new instantiated AccountCache object

func (*AccountCache) GetByID

func (c *AccountCache) GetByID(id string) (*gtsmodel.Account, bool)

GetByID attempts to fetch a account from the cache by its ID, you will receive a copy for thread-safety

func (*AccountCache) GetByURI

func (c *AccountCache) GetByURI(uri string) (*gtsmodel.Account, bool)

GetByURI attempts to fetch a account from the cache by its URI, you will receive a copy for thread-safety

func (*AccountCache) GetByURL

func (c *AccountCache) GetByURL(url string) (*gtsmodel.Account, bool)

GetByURL attempts to fetch a account from the cache by its URL, you will receive a copy for thread-safety

func (*AccountCache) Put

func (c *AccountCache) Put(account *gtsmodel.Account)

Put places a account in the cache, ensuring that the object place is a copy for thread-safety

type Cache

type Cache interface {
	Store(k string, v interface{}) error
	Fetch(k string) (interface{}, error)
}

Cache defines an in-memory cache that is safe to be wiped when the application is restarted

func New

func New() Cache

New returns a new in-memory cache.

type Error

type Error error

Error models an error returned by the in-memory cache.

type StatusCache

type StatusCache struct {
	// contains filtered or unexported fields
}

StatusCache is a wrapper around ttlcache.Cache to provide URL and URI lookups for gtsmodel.Status

func NewStatusCache

func NewStatusCache() *StatusCache

NewStatusCache returns a new instantiated statusCache object

func (*StatusCache) GetByID

func (c *StatusCache) GetByID(id string) (*gtsmodel.Status, bool)

GetByID attempts to fetch a status from the cache by its ID, you will receive a copy for thread-safety

func (*StatusCache) GetByURI

func (c *StatusCache) GetByURI(uri string) (*gtsmodel.Status, bool)

GetByURI attempts to fetch a status from the cache by its URI, you will receive a copy for thread-safety

func (*StatusCache) GetByURL

func (c *StatusCache) GetByURL(url string) (*gtsmodel.Status, bool)

GetByURL attempts to fetch a status from the cache by its URL, you will receive a copy for thread-safety

func (*StatusCache) Put

func (c *StatusCache) Put(status *gtsmodel.Status)

Put places a status in the cache, ensuring that the object place is a copy for thread-safety

Jump to

Keyboard shortcuts

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