cache

package
v1.0.6 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2020 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultEvery = 60 // 1 minute
)

Functions

func Register

func Register(name string, adapter Cache)

Types

type Cache

type Cache interface {
	Get(key string) interface{}
	Set(key string, val interface{}, timeout time.Duration) error
	Delete(key string) error
	IsExist(key string) bool
	Init(cfg interface{}) error
}

Cache interface

func NewCache

func NewCache(adapterName string, config interface{}) (adapter Cache, err error)

func NewMemCache

func NewMemCache() Cache

func NewMemoryCache

func NewMemoryCache() Cache

func NewRedisCache

func NewRedisCache() Cache

type MemCache

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

func (*MemCache) Delete

func (rc *MemCache) Delete(key string) error

func (*MemCache) Get

func (rc *MemCache) Get(key string) interface{}

func (*MemCache) Init

func (rc *MemCache) Init(cfg interface{}) error

func (*MemCache) IsExist

func (rc *MemCache) IsExist(key string) bool

func (*MemCache) Set

func (rc *MemCache) Set(key string, val interface{}, timeout time.Duration) error

type MemOpts

type MemOpts struct {
	Conn string
}

type MemoryCache

type MemoryCache struct {
	sync.RWMutex

	Every int
	// contains filtered or unexported fields
}

func (*MemoryCache) Delete

func (bc *MemoryCache) Delete(name string) error

func (*MemoryCache) Get

func (bc *MemoryCache) Get(name string) interface{}

func (*MemoryCache) Init

func (bc *MemoryCache) Init(cfg interface{}) error

func (*MemoryCache) IsExist

func (bc *MemoryCache) IsExist(name string) bool

func (*MemoryCache) Set

func (bc *MemoryCache) Set(name string, value interface{}, lifespan time.Duration) error

type MemoryItem

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

type MemoryOpts

type MemoryOpts struct {
	Interval int
}

type Redis

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

Redis redis cache

func (*Redis) Delete

func (r *Redis) Delete(key string) error

func (*Redis) Get

func (r *Redis) Get(key string) interface{}

func (*Redis) Init

func (r *Redis) Init(cfg interface{}) error

func (*Redis) IsExist

func (r *Redis) IsExist(key string) bool

func (*Redis) Set

func (r *Redis) Set(key string, val interface{}, timeout time.Duration) (err error)

func (*Redis) SetConn

func (r *Redis) SetConn(conn *redis.Pool)

type RedisOpts

type RedisOpts struct {
	Host        string
	Password    string
	Database    int
	MaxIdle     int
	MaxActive   int
	IdleTimeout int32
}

Jump to

Keyboard shortcuts

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