cache

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2022 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ICache

type ICache interface {
	Get(key string) (any, bool)
	Set(key string, value any, expire time.Duration) bool
	SetWithCost(key string, value any, cost int64, expire time.Duration) bool
	Del(key string)
}
var (
	Cache ICache
)

func InitCache

func InitCache(name string, config *viper.Viper, fn func(any) error) ICache

type Redis

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

Default implemented cache strategy: LRU

func (*Redis) Del

func (client *Redis) Del(key string)

func (*Redis) Get

func (client *Redis) Get(key string) (any, bool)

func (*Redis) Set

func (client *Redis) Set(key string, value any, expire time.Duration) bool

func (*Redis) SetWithCost

func (client *Redis) SetWithCost(key string, value any, cost int64, expire time.Duration) bool

type Ristretto

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

func (*Ristretto) Del

func (client *Ristretto) Del(key string)

func (*Ristretto) Get

func (client *Ristretto) Get(key string) (any, bool)

func (*Ristretto) Set

func (client *Ristretto) Set(key string, value any, expire time.Duration) bool

func (*Ristretto) SetWithCost

func (client *Ristretto) SetWithCost(key string, value any, cost int64, expire time.Duration) bool

Jump to

Keyboard shortcuts

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