ured

package module
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2019 License: MIT Imports: 3 Imported by: 0

README

ured(util of redis)

使用 github.com/mediocregopher/radix操作redis.

简单的封装. Do + Cmd + FlatCmd + Pipeline, and type alias.

样例

package main

import (
	"github.com/michelia/ured"
	"github.com/michelia/ulog"
)

func main() {
	c := ured.Config{
		Addr:      "127.0.0.1:6379",
		Passwd:    "xxxxx",
		DbNum:     3,
	}
	slog := ulog.NewConsole()
	red := ured.New(slog, c)
	_ = red.Do(nil, "SET", "foo", "someval")
	foo := ""
	_ = red.Do(&foo, "GET", "foo", "someval")
	slog.Print("foo: "foo)
	// print
	// foo: someval
}

参考

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Cmd     = radix.Cmd
	FlatCmd = radix.FlatCmd
)

Functions

This section is empty.

Types

type CmdAction

type CmdAction = radix.CmdAction

type Config

type Config struct {
	Addr        string
	Passwd      string
	DbNum       int
	DialTimeout int // 建立连接, 默认为10s
	PoolSize    int // 连接池大小, 默认为10
}

type Red

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

func New

func New(slog ulog.Logger, c Config) *Red

func (*Red) Do

func (r *Red) Do(rcv interface{}, cmd string, args ...string) error

Do 简单封装了 pool.Do + Cmd

func (*Red) DoFlat

func (r *Red) DoFlat(rcv interface{}, cmd, key string, args ...interface{}) error

DoFlat 简单封装了 pool.Do + FlatCmd

func (*Red) DoPipeline

func (r *Red) DoPipeline(cmds ...CmdAction) error

DoPipeline 简单封装了 pool.Do + DoPipeline +

Jump to

Keyboard shortcuts

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