redis

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2023 License: MIT Imports: 10 Imported by: 1

Documentation

Overview

* @Author: liziwei01 * @Date: 2022-03-04 15:43:21 * @LastEditors: liziwei01 * @LastEditTime: 2023-11-01 11:19:03 * @Description: file content

* @Author: liziwei01 * @Date: 2022-03-04 13:52:11 * @LastEditors: liziwei01 * @LastEditTime: 2023-10-29 11:33:44 * @Description: file content

* @Author: liziwei01 * @Date: 2022-03-04 15:42:58 * @LastEditors: liziwei01 * @LastEditTime: 2023-03-30 23:16:33 * @Description: file content

* @Author: liziwei01 * @Date: 2022-03-21 22:36:04 * @LastEditors: liziwei01 * @LastEditTime: 2023-10-29 12:44:24 * @Description: file content

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	// GetStr 获取value
	Get(ctx context.Context, key string) (value string, err error)
	// Set 将字符串值 value 关联到 key
	// 如果 key 已经存在, SET 将覆盖旧值 无视类型
	// 过期时间为 nanoseconds 纳秒
	Set(ctx context.Context, key string, value string, expireTime ...time.Duration) error
	// Del
	Del(ctx context.Context, keys ...string) error
	// Determine if a key exists
	Exists(ctx context.Context, keys ...string) (int64, error)
	// contains filtered or unexported methods
}

func GetClient

func GetClient(ctx context.Context, serviceName string) (Client, error)

*

  • @description:
  • @param {context.Context} ctx
  • @param {string} serviceName
  • @return {*}

func New

func New(config *Config) Client

type Config

type Config struct {
	// Service的名字, 必选
	Name string

	// 各种自定义的参数, 全部非必选
	// 写数据超时
	WriteTimeOut int
	// 读数据超时
	ReadTimeOut int
	// 请求失败后的重试次数: 总请求次数 = Retry + 1
	Retry int

	// 资源定位: 手动配置 - 使用IP、端口
	Resource struct {
		Manual struct {
			Host string
			Port int
		}
	}

	Redis struct {
		Password string
		DB       int
	}
}

Config 配置

Jump to

Keyboard shortcuts

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