redigo_pack

package module
v0.0.0-...-cdb8f43 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2020 License: MIT Imports: 5 Imported by: 0

README

redis的使用更简单

说明

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

安装

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

使用

package main

import (
	"fmt"

	"github.com/newgoo/redigo-pack"
)

func init() {
	redigo_pack.NewConnectionWithFile("redis", "./config/config.ini")
}

func main() {
	err := redigo_pack.RedigoConn.String.Set("1", 2, 10).Error()
	if err != nil {
		fmt.Println(err)
		return
	}
	v, err := redigo_pack.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

func NewConnection

func NewConnection()

func NewConnectionWithFile

func NewConnectionWithFile(tagName, path string) error

Types

type Config

type Config struct {
	Host      string `ini:"host"`
	Port      int64  `ini:"port"`
	Db        int64  `ini:"db"`
	Password  string `ini:"password"`
	MaxIdle   int    `ini:"max_idle"`   //default 10  最大连接数
	MaxActive int    `ini:"max_active"` //default 10000 连接池最大数
	Wait      bool   `ini:"wait"`
}

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