cache

package
v0.1.8 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2022 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Get

func Get(ctx context.Context, key string) (interface{}, error)

func InitCache added in v0.0.3

func InitCache(name string, opt CacheOption)

func Overdue

func Overdue(ctx context.Context, key interface{}) bool

func Set

func Set(ctx context.Context, key string, value interface{}) (interface{}, error)

func SetEx

func SetEx(ctx context.Context, key string, value interface{}, sec int) (interface{}, error)

Types

type Cache

type Cache interface {
	Get(ctx context.Context, key string) (interface{}, error)
	Set(ctx context.Context, key string, value interface{}) (interface{}, error)
	Overdue(ctx context.Context, key interface{}) bool
	SetEx(ctx context.Context, key string, value interface{}, sec int) (interface{}, error)
}

func NewCacheBaseRedis

func NewCacheBaseRedis(opt CacheOption) Cache

new cache base redis

type CacheBaseRedis

type CacheBaseRedis struct {
	Pool *redigo.Pool
}

func (*CacheBaseRedis) Get

func (c *CacheBaseRedis) Get(ctx context.Context, key string) (interface{}, error)

func (*CacheBaseRedis) Overdue

func (c *CacheBaseRedis) Overdue(ctx context.Context, key interface{}) bool

func (*CacheBaseRedis) Set

func (c *CacheBaseRedis) Set(ctx context.Context, key string, value interface{}) (interface{}, error)

func (*CacheBaseRedis) SetEx

func (c *CacheBaseRedis) SetEx(ctx context.Context, key string, value interface{}, sec int) (interface{}, error)

type CacheOption

type CacheOption struct {
	Host        string
	Auth        bool
	Username    string
	Password    string
	Database    string
	Table       string
	DB          int
	MaxIdle     int
	IdleTimeout time.Duration
	MaxActive   int
}

Jump to

Keyboard shortcuts

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