msredis

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2021 License: MIT Imports: 8 Imported by: 1

README

Language License

Introduction

A master-slave redis client implement based on GoFrame redis

Keywords

GoFrame redis master slave

Quick Start

package main

import (
	"github.com/hetiansu5/msredis"
)

masterName := "cache" // master redis config name
slaveName := "cache_slave" // slave redis config name, can be more
group := msredis.Group(masterName, slaveName)
group.CTX(ctx).Do("GET", "key1")

License

MIT

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type RedisGroup

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

func Group

func Group(name ...string) *RedisGroup

func New

func New(name ...string) *RedisGroup

func (*RedisGroup) Clone

func (r *RedisGroup) Clone() *RedisGroup

Clone clones and returns a new Redis object, which is a shallow copy of current one.

func (*RedisGroup) Ctx

func (r *RedisGroup) Ctx(ctx context.Context) *RedisGroup

Ctx is a channing function which sets the context for next operation.

func (*RedisGroup) Do

func (r *RedisGroup) Do(commandName string, args ...interface{}) (interface{}, error)

Do sends a command to the server and returns the received reply. Do automatically get a connection from pool, and close it when the reply received. It does not really "close" the connection, but drops it back to the connection pool.

func (*RedisGroup) DoVar

func (r *RedisGroup) DoVar(commandName string, args ...interface{}) (*gvar.Var, error)

DoVar returns value from Do as gvar.Var.

func (*RedisGroup) DoVarWithTimeout

func (r *RedisGroup) DoVarWithTimeout(timeout time.Duration, commandName string, args ...interface{}) (*gvar.Var, error)

DoVarWithTimeout returns value from Do as gvar.Var. The timeout overrides the read timeout set when dialing the connection.

func (*RedisGroup) DoWithTimeout

func (r *RedisGroup) DoWithTimeout(timeout time.Duration, commandName string, args ...interface{}) (interface{}, error)

DoWithTimeout sends a command to the server and returns the received reply. The timeout overrides the read timeout set when dialing the connection.

func (*RedisGroup) Master

func (r *RedisGroup) Master() *gredis.Redis

func (*RedisGroup) Slave

func (r *RedisGroup) Slave() *gredis.Redis

Jump to

Keyboard shortcuts

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