cache

package
v0.11.9 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache interface {
	IsOK() error
	Get(key string, data interface{}) error
	Delete(key string) error
	Set(key string, value interface{}, expire time.Duration) error
	Expire(key string, expire time.Duration) error
	EnQueue(key string, value interface{}) error
	DeQueue(key string) (interface{}, error)
}

Cache

type Config

type Config struct {
	Engine   string `toml:"engine"`
	Host     string `toml:"host"`
	Port     string `toml:"port"`
	Pass     string `toml:"pass"`
	DB       int    `toml:"db"`
	LifeTime int64  `toml:"life_time"`
}

Redis Config

type Redis

type Redis struct {
	Client *redis.Client
}

Redis client

func NewRedis

func NewRedis(config Config) *Redis

NewRedis 实例化一个redis缓存

func (*Redis) DeQueue

func (r *Redis) DeQueue(key string) (interface{}, error)

DeQueue

func (*Redis) Delete

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

Delete

func (*Redis) EnQueue

func (r *Redis) EnQueue(key string, value interface{}) error

EnQueue

func (*Redis) Expire added in v0.11.4

func (r *Redis) Expire(key string, expire time.Duration) error

Expire

func (*Redis) Get

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

Get

func (*Redis) IsOK

func (r *Redis) IsOK() error

IsOK pings the redis server and check server's pong response

func (*Redis) Set

func (r *Redis) Set(key string, value interface{}, expire time.Duration) error

Set

Jump to

Keyboard shortcuts

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