cache

package
v4.19.1 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2023 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

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

func NewCache

func NewCache(fc Store, sf *singleflight.Group) *Cache

func (*Cache) Clear

func (c *Cache) Clear(key contracts.CacheKeyInterface) error

func (*Cache) Remember

func (c *Cache) Remember(key contracts.CacheKeyInterface, seconds int, fn func() ([]byte, error)) ([]byte, error)

func (*Cache) SetWithTTL

func (c *Cache) SetWithTTL(key contracts.CacheKeyInterface, value []byte, seconds int) error

type DBCache

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

func NewDBCache

func NewDBCache(sf *singleflight.Group, dbFunc func() *gorm.DB) *DBCache

func (*DBCache) Clear

func (c *DBCache) Clear(key contracts.CacheKeyInterface) error

func (*DBCache) Remember

func (c *DBCache) Remember(key contracts.CacheKeyInterface, seconds int, fn func() ([]byte, error)) ([]byte, error)

func (*DBCache) SetWithTTL

func (c *DBCache) SetWithTTL(key contracts.CacheKeyInterface, value []byte, seconds int) error

type Key

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

func NewKey

func NewKey(slug string, vals ...any) *Key

func (*Key) Slug

func (c *Key) Slug() string

func (*Key) String

func (c *Key) String() string

type MetricsForCache

type MetricsForCache struct {
	Cache contracts.CacheInterface
}

func NewMetricsForCache

func NewMetricsForCache(c contracts.CacheInterface) *MetricsForCache

func (*MetricsForCache) Clear

func (*MetricsForCache) Remember

func (m *MetricsForCache) Remember(key contracts.CacheKeyInterface, seconds int, fn func() ([]byte, error)) ([]byte, error)

func (*MetricsForCache) SetWithTTL

func (m *MetricsForCache) SetWithTTL(key contracts.CacheKeyInterface, value []byte, seconds int) error

type NoCache

type NoCache struct{}

func (*NoCache) Clear

func (n *NoCache) Clear(key contracts.CacheKeyInterface) error

func (*NoCache) Remember

func (n *NoCache) Remember(key contracts.CacheKeyInterface, seconds int, fn func() ([]byte, error)) ([]byte, error)

func (*NoCache) SetWithTTL

func (n *NoCache) SetWithTTL(key contracts.CacheKeyInterface, value []byte, seconds int) error

type Store

type Store interface {
	Get(key string) (value []byte, err error)
	Set(key string, value []byte, expireSeconds int) (err error)
	Delete(key string) error
}

Jump to

Keyboard shortcuts

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