redigo_pack

package module
v1.5.2 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2021 License: MIT Imports: 2 Imported by: 0

README

redis的使用更简单

说明

基于redigo的封装,写入好配置文件后,在任何地方随时调用,使用起来更简单,代码更优雅 支持和redigo同时使用

安装

go get -u -v github.com/chensanle/redigo-pack

使用

package main

import (
	"fmt"

	"github.com/chensanle/redigo-pack"
	"github.com/gomodule/redigo/redis"
)

var RedigoConn = redigo_pack.NewConnectionByPool(&redis.Pool{})

func main() {
	err := RedigoConn.String.Set("1", 2, 10).Error()
	if err != nil {
		fmt.Println(err)
		return
	}
	v, err := RedigoConn.String.Get("1").Int64()
	if err != nil {
		fmt.Println(err)
		return
	}
	fmt.Println(v)
}

License

The MIT License.

联系我

如果有不足的地方,需要添加的请联系我 newgoo: happs.lives@gmail.com

感谢

vichuyongqiang提供的list的封装

Documentation

Overview

基于redigo的封装

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrorConfig error = fmt.Errorf("请先初始化redis配置")
)
View Source
var NilError = redis.ErrNil
View Source
var RedigoConn = new(RedigoPack)

Functions

This section is empty.

Types

type RedigoPack

type RedigoPack struct {
	String stringRds
	List   listRds
	Hash   hashRds
	Key    keyRds
	Set    setRds
	ZSet   zSetRds
	Bit    bitRds
	Db     dbRds
}

func NewConnectionByPool

func NewConnectionByPool(p *redis.Pool) *RedigoPack

func (*RedigoPack) GetConn added in v1.5.2

func (p *RedigoPack) GetConn() redis.Conn

Note! release the conn

func (*RedigoPack) GetPubSubConn added in v1.5.2

func (p *RedigoPack) GetPubSubConn() *redis.PubSubConn

Note! release the conn

type Reply

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

func (*Reply) Bool

func (r *Reply) Bool() (bool, error)

func (*Reply) ByteSlices

func (r *Reply) ByteSlices() ([][]byte, error)

func (*Reply) Bytes

func (r *Reply) Bytes() ([]byte, error)

func (*Reply) Error

func (r *Reply) Error() error

func (*Reply) Float64s

func (r *Reply) Float64s() ([]float64, error)

func (*Reply) Int

func (r *Reply) Int() (int, error)

func (*Reply) Int64

func (r *Reply) Int64() (int64, error)

func (*Reply) Int64Map

func (r *Reply) Int64Map() (map[string]int64, error)

func (*Reply) Int64s

func (r *Reply) Int64s() ([]int64, error)

func (*Reply) IntMap

func (r *Reply) IntMap() (map[string]int, error)

func (*Reply) Ints

func (r *Reply) Ints() ([]int, error)

func (*Reply) Positions

func (r *Reply) Positions() ([]*[2]float64, error)

func (*Reply) Result

func (r *Reply) Result() (interface{}, error)

func (*Reply) ScanStruct

func (r *Reply) ScanStruct(obj interface{}) error

obj为一个指针对象

func (*Reply) String

func (r *Reply) String() (string, error)

func (*Reply) StringMap

func (r *Reply) StringMap() (map[string]string, error)

func (*Reply) Strings

func (r *Reply) Strings() ([]string, error)

func (*Reply) Uint64

func (r *Reply) Uint64() (uint64, error)

func (*Reply) Values

func (r *Reply) Values() ([]interface{}, error)

Jump to

Keyboard shortcuts

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