cache

package
v0.2.0 Latest Latest
Warning

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

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

Documentation

Overview

Package cache universal tool package

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

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

Cache interface

type Redis

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

Redis .redis cache

func NewRedis

func NewRedis(_ context.Context, opts *RedisOpts) *Redis

NewRedis 实例化

func (*Redis) Delete

func (r *Redis) Delete(ctx context.Context, key string) error

Delete 删除

func (*Redis) Get

func (r *Redis) Get(ctx context.Context, key string) interface{}

Get 获取一个值

func (*Redis) IsExist

func (r *Redis) IsExist(ctx context.Context, key string) bool

IsExist 判断 key 是否存在

func (*Redis) Set

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

Set 设置一个值

func (*Redis) SetConn

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

SetConn 设置 conn

type RedisOpts

type RedisOpts struct {
	Host        string `yml:"host" json:"host"`
	Password    string `yml:"password" json:"password"`
	Database    int    `yml:"database" json:"database"`
	MaxIdle     int    `yml:"max_idle" json:"max_idle"`
	IdleTimeout int    `yml:"idle_timeout" json:"idle_timeout"`
}

RedisOpts Redis 连接属性

func NewDefaultRedisOpts

func NewDefaultRedisOpts() *RedisOpts

NewDefaultRedisOpts 实例化

Jump to

Keyboard shortcuts

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