cacheable

package
v0.0.0-...-1b39580 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const KeyPrefix = "Cache"

Variables

View Source
var EmptyCacheError = errors.New("Cachable: No results found")

Functions

func Del

func Del(ctx context.Context, key string)

func DelByTag

func DelByTag(ctx context.Context, tag string)

func Expire

func Expire(key string, expire time.Duration)

func Get

func Get(ctx context.Context, key string) string

func GetFromFallBack

func GetFromFallBack(ctx context.Context, key string) string

func GetKeys

func GetKeys(ctx context.Context, tag string) []string

func GetList

func GetList(ctx context.Context, key string, start, stop int64) ([]string, error)

func Has

func Has(key string) bool

func Set

func Set(key, value string, expire time.Duration)

func SetUpRedis

func SetUpRedis(db int, Cluster int)

func SetUpRedisCluster

func SetUpRedisCluster(nodes []string) error

func Tag

func Tag(tag, key string) bool

Types

type Cache

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

type Cacheable

type Cacheable struct {
	LastUpdated time.Time `json:"last_updated,omitempty"`
	// contains filtered or unexported fields
}

func NewCachable

func NewCachable(prefix, id string, parentPtr ICacheable) (*Cacheable, error)

func (*Cacheable) Get

func (c *Cacheable) Get(ctx context.Context) error

func (*Cacheable) GetKey

func (c *Cacheable) GetKey() string

func (*Cacheable) Set

func (c *Cacheable) Set(expire time.Duration) error

type ICacheable

type ICacheable interface {
	GetKey() string
	Get() error
	Set(expire time.Duration) error
}

type Tags

type Tags []string

Jump to

Keyboard shortcuts

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