gredis

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2021 License: Apache-2.0 Imports: 7 Imported by: 0

README

缓存组件(redis)

如何引用

  1. 代码
import (
    _ "github.com/GuoxinL/gcomponent/components/cache"
)
  1. 配置文件(application.yaml)
components:
  redis:
    rds:
        # redis名称
      - name: test
        # 集群节点
        nodes:
          - 192.168.155.81:7378
          - 192.168.155.82:7378
          - 192.168.155.235:7378
          - 192.168.155.81:7379
          - 192.168.155.82:7379
          - 192.168.155.235:7379
        # 密码
        password: test
        # 连接池配置
        pool:
          maxIdle: 10
          idleTimeout: 240
          maxConnLifetime: 300
        # 连接超时配置
        connection:
          readTimeout: 50
          writeTimeout: 50
          connectTimeout: 50

如何使用

  1. func (this *clusterWrapper) Get(key string) (string, error)

注释:get 参数:key 返回值:value, err 2. func (this *clusterWrapper) Set(key string, value interface{}) (string, error) 注释:set 参数:key, value 返回值:value, err

Documentation

Overview

Package gredis Created by guoxin in 2020/4/13 1:34 下午

Index

Constants

This section is empty.

Variables

View Source
var DefaultOptions = &redis.Options{

	Network:  "tcp",
	Addr:     "127.0.0.1:6379",
	Password: "",
	DB:       0,

	PoolSize: 15,

	DialTimeout:  5 * time.Second,
	ReadTimeout:  3 * time.Second,
	WriteTimeout: 3 * time.Second,
	PoolTimeout:  4 * time.Second,

	IdleCheckFrequency: 60 * time.Second,
	IdleTimeout:        5 * time.Minute,

	MaxRetries: 0,
	ReadOnly:   false,
	TLSConfig:  nil,
	Dialer:     nil,
}

Functions

func GetInstance

func GetInstance(name string) redis.Cmdable

GetInstance 通过该方法获得 *redis.Cmdable 对象

func New

func New(params ...interface{})

Types

type Configuration

type Configuration struct {
	core.InitializeLock
	RedisSources []RedisSource `mapstructure:"rds"`
}

func (*Configuration) Initialize

func (c *Configuration) Initialize(params ...interface{}) interface{}

type RedisSource

type RedisSource struct {
	core.InitializeLock
	Name          string                `mapstructure:"name"`
	Cluster       *redis.ClusterOptions `mapstructure:"Cluster"`
	redis.Options `mapstructure:",squash"`
}

Jump to

Keyboard shortcuts

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