redis

package module
v1.0.9 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2023 License: MPL-2.0 Imports: 8 Imported by: 2

README

缓存Redis单实例

配置中心的配置路径为:/system/base/cache/provider

基于Redis单实例的缓存实现(单机),配置中心或构造方法中参数的配置格式如下:

{
    "host" : "缓存服务器主机地址,必须",
    "port" : "缓存服务器端口号",
    "sasl" : "是否开启安全认证,true|false,可选,默认是没有",
    "password" : "开启安全认证后的登录密码,sasl如果指定为true则必须"
 }

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type SingleRedisProvider

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

*

  • SingleRedisProvider
  • 基于Redis单实例的缓存实现(单机),配置中心或构造方法中参数的配置格式如下:
  • <pre>
  • {
  • "host" : "缓存服务器主机地址,必须",
  • "port" : "缓存服务器端口号",
  • "sasl" : "是否开启安全认证,true|false,可选,默认是没有",
  • "password" : "开启安全认证后的登录密码,sasl如果指定为true则必须"
  • }
  • </pre>

func (SingleRedisProvider) BatchDelete

func (r SingleRedisProvider) BatchDelete(ctx context.Context, keys ...string) bool

BatchDelete 批量删除缓存中的key。

func (SingleRedisProvider) Client added in v1.0.9

func (r SingleRedisProvider) Client() interface{}

func (SingleRedisProvider) Close

func (r SingleRedisProvider) Close()

Close 关闭客户端

func (SingleRedisProvider) Delete

func (r SingleRedisProvider) Delete(ctx context.Context, key string) bool

Delete 从缓存中删除指定key的缓存数据。

func (SingleRedisProvider) Exists

func (r SingleRedisProvider) Exists(ctx context.Context, key string) bool

Exists 判断缓存中是否存在指定的key

func (SingleRedisProvider) HDelete

func (r SingleRedisProvider) HDelete(ctx context.Context, key string, fields ...string) bool

HDelete 将指定key的map数据中的某个字段删除。

func (SingleRedisProvider) HExists

func (r SingleRedisProvider) HExists(ctx context.Context, key, field string) bool

HExists 判断缓存中指定key的map是否存在指定的字段,如果key或字段不存在则返回false。

func (SingleRedisProvider) HGet

func (r SingleRedisProvider) HGet(ctx context.Context, key, field string) string

HGet 获取指定key的map数据某个字段的值,如果不存在则返回Null

func (SingleRedisProvider) HGetAll

func (r SingleRedisProvider) HGetAll(ctx context.Context, key string) map[string]string

HGetAll 获取指定key的map对象,如果不存在则返回Null

func (SingleRedisProvider) HSet

func (r SingleRedisProvider) HSet(ctx context.Context, key, field, value string) bool

HSet 将指定key的map数据的某个字段设置为给定的值。

func (SingleRedisProvider) Incr added in v1.0.4

func (r SingleRedisProvider) Incr(ctx context.Context, key string) bool

Incr 对指定的key结果集执行自增操作

func (SingleRedisProvider) IncrByExpires added in v1.0.5

func (r SingleRedisProvider) IncrByExpires(ctx context.Context, key string, value int64, expires time.Duration) bool

func (SingleRedisProvider) IncrExpires added in v1.0.5

func (r SingleRedisProvider) IncrExpires(ctx context.Context, key string, expires time.Duration) bool

func (SingleRedisProvider) LIndex added in v1.0.8

func (r SingleRedisProvider) LIndex(ctx context.Context, key string, index int64) string

func (SingleRedisProvider) LLen added in v1.0.8

func (r SingleRedisProvider) LLen(ctx context.Context, key string) int64

func (SingleRedisProvider) LPop added in v1.0.8

func (r SingleRedisProvider) LPop(ctx context.Context, key string) string

func (SingleRedisProvider) LPush added in v1.0.8

func (r SingleRedisProvider) LPush(ctx context.Context, key string, value ...interface{}) bool

func (SingleRedisProvider) LRange added in v1.0.8

func (r SingleRedisProvider) LRange(ctx context.Context, key string, start, stop int64) []string

func (*SingleRedisProvider) Operate

func (r *SingleRedisProvider) Operate(ctx context.Context, cmd interface{}) error

Operate 通过直接调用缓存客户端进行缓存操作,该操作适用于高级操作,如果执行失败会返回Null。

func (SingleRedisProvider) RPop added in v1.0.8

func (r SingleRedisProvider) RPop(ctx context.Context, key string) string

func (SingleRedisProvider) RPush added in v1.0.8

func (r SingleRedisProvider) RPush(ctx context.Context, key string, value ...interface{}) bool

func (SingleRedisProvider) SAdd added in v1.0.7

func (r SingleRedisProvider) SAdd(ctx context.Context, key string, members ...interface{}) bool

func (SingleRedisProvider) SCard added in v1.0.7

func (r SingleRedisProvider) SCard(ctx context.Context, key string) int64

func (SingleRedisProvider) SMembers added in v1.0.6

func (r SingleRedisProvider) SMembers(ctx context.Context, key string) []string

func (SingleRedisProvider) Set

func (r SingleRedisProvider) Set(ctx context.Context, key, value string) bool

Set 使用指定的key将对象存入分布式缓存中,并使用缓存的默认过期设置,注意,存入的对象必须是可序列化的。

func (SingleRedisProvider) SetExpires

func (r SingleRedisProvider) SetExpires(ctx context.Context, key, value string, expires time.Duration) bool

SetExpires 使用指定的key将对象存入分部式缓存中,并指定过期时间,注意,存入的对象必须是可序列化的

func (SingleRedisProvider) SetNX added in v1.0.6

func (r SingleRedisProvider) SetNX(ctx context.Context, key, value string, expires time.Duration) bool

func (SingleRedisProvider) String

func (r SingleRedisProvider) String(ctx context.Context, key string) string

String 根据给定的key从分布式缓存中读取数据并返回,如果不存在或已过期则返回Null。

func (SingleRedisProvider) Val

func (r SingleRedisProvider) Val(ctx context.Context, script string, keys []string, args ...interface{}) string

Val 对指定的key结果集执行指定的脚本并返回最终脚本执行的结果。

Jump to

Keyboard shortcuts

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