cache

package
v2.3.55 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NeverExpire = time.Duration(0)
)

Variables

View Source
var Nil = redis.Nil

Functions

This section is empty.

Types

type API

type API interface {
	PTTL(ctx context.Context, key string) *redis.DurationCmd

	Get(ctx context.Context, key string) *redis.StringCmd
	Set(ctx context.Context, key string, value interface{}, expiration time.Duration) *redis.StatusCmd
}

type Cache

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

func New

func New(cfg RedisConfig) (cache *Cache)

func (*Cache) GetTTL

func (rc *Cache) GetTTL(ctx context.Context, key string, value interface{}) (createdAt time.Time, ttl time.Duration, err error)

func (*Cache) R

func (rc *Cache) R() API

func (*Cache) SetTTL

func (rc *Cache) SetTTL(ctx context.Context, key string, value interface{}, ttl time.Duration) (err error)

type RedisConfig

type RedisConfig struct {
	Address  string `envconfig:"REDIS_ADDRESS" default:"127.0.0.1:6379"`
	Username string `envconfig:"REDIS_USER"`
	Password string `envconfig:"REDIS_PASSWORD"`
	Database int    `envconfig:"REDIS_DATABASE" default:"0"`
	PoolSize int    `envconfig:"REDIS_POOL_SIZE" default:"10"`
}

Jump to

Keyboard shortcuts

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