redisDB

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2020 License: MPL-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetRediClient

func GetRediClient(config map[string]string) (*redis.Client, error)

Types

type IRedisRepository

type IRedisRepository interface {
	// 插入单个
	// entity  结构体
	// expSecond   0为永不到期
	Set(key string, entity interface{}, expiration time.Duration) (int64, error)

	// 插入多个
	// entityMap 结构体字典
	// expSecond   0为永不到期
	SetMany(entityMap map[string]interface{}, expiration time.Duration) (int64, error)

	//添加加字符串
	Append(key string, value string) (int64, error)

	// 删除单个
	// key key值
	Remove(key ...string) (int64, error)

	//查询单个
	// key         key值
	// result      查询的结果
	Get(key string, result interface{}) error

	//查询多个[只支持string类型]
	// keys        key值切片
	// result      查询的结果切片
	GetMany(keys []string, result interface{}) error
}

redis 仓储接口(只支持string类型)

type RedisContent

type RedisContent struct {
	Client *redis.Client
}

集合上下文

func DataBaseMapping

func DataBaseMapping(client *redis.Client) *RedisContent

添加映射 @client 连接对象 @dataName 数据库名

func (*RedisContent) GetRedisRepository

func (redi *RedisContent) GetRedisRepository(entity interface{}) IRedisRepository

获取集合仓储 entity 结构体

type ReidsRepository

type ReidsRepository struct {
	Client     *redis.Client
	EntityNmae string
}

Reids 仓储(string)

func (*ReidsRepository) Append

func (redi *ReidsRepository) Append(key string, value string) (int64, error)

往key后面添加字符串 key key值 value 要添加的字符串

func (*ReidsRepository) Get

func (reid *ReidsRepository) Get(key string, result interface{}) error

查询单个 key key值 result 查询的结果

func (*ReidsRepository) GetMany

func (reid *ReidsRepository) GetMany(keys []string, result interface{}) error

查询多个 keys key值切片 result 查询的结果切片

func (*ReidsRepository) Remove

func (redi *ReidsRepository) Remove(keys ...string) (int64, error)

移除 keys key值切片

func (*ReidsRepository) Set

func (redi *ReidsRepository) Set(key string, entity interface{}, expiration time.Duration) (int64, error)

插入单个[key数据存在会更新] entity 结构体 expSecond 0为永不到期

func (*ReidsRepository) SetMany

func (redi *ReidsRepository) SetMany(entityMap map[string]interface{}, expiration time.Duration) (int64, error)

插入多个 [key数据存在会更新] entityMap 结构体字典 expSecond 0为永不到期

Jump to

Keyboard shortcuts

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