rediso

package module
v0.0.0-...-20fb5f7 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2016 License: MIT Imports: 5 Imported by: 0

README

This is a redis client written in golang.

Basic usage.

func main() {
	conn := rediso.Connect(nil)
	conn.Exec(rediso.SET, "name", "leaxoy")
	conn.Exec(rediso.GET, "name")
	s := conn.Ping() // should return "+PONG"
	println(s)
	db := conn.DB() // should return 0
	println(db)
	conn.SelectDB(1) // change db to 1
	db = conn.DB()   //should return 1
	println(db)
  conn.Close()
}

Config is redis config.

{
  host    string        // default is `localhost`
  port    int           // default is 6379
  ssl     bool          // use ssl. default is false
  timeout time.Duration // default is 5's
  db      int           // default is 0
}

Documentation

Index

Constants

View Source
const (
	// GET is get command. usage: GET key
	GET = "GET"
	// SET is set command. usage: SET key value
	SET = "SET"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client is Redis conn.

func NewRedis

func NewRedis(config *Config) *Client

NewRedis create new redis conn

func (*Client) Auth

func (c *Client) Auth(auth string) bool

Auth is a function to auth to redis server.

func (*Client) Close

func (c *Client) Close()

Close is a function that close connection to redis server.

func (*Client) Conn

func (c *Client) Conn() *Client

Conn return the current client.

func (*Client) DB

func (c *Client) DB() int

DB method return the current DB index.

func (*Client) Exec

func (c *Client) Exec(command string, args ...string) interface{}

Exec is a directly function

func (*Client) ExecQuery

func (c *Client) ExecQuery(query *Query)

ExecQuery is a function to exec command on redis conn

func (*Client) HostInfo

func (c *Client) HostInfo() string

HostInfo return the redis server info.

func (*Client) Info

func (c *Client) Info() string

Info is a method that return info of redis server.

func (*Client) Ping

func (c *Client) Ping() string

Ping is a function that ping to redis server.

func (*Client) SelectDB

func (c *Client) SelectDB(db int) *DB

SelectDB is a function that change db index.

type Config

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

Config is redis connection config.

type Conn

type Conn interface {
	Auth(auth string) bool
	Conn() *Client
	DB() int
	ExecQuery(query *Query)
	Exec(command string, args ...string) interface{}
	SelectDB(db int) *DB
	Info() string
	HostInfo() string
	Ping() string
	Close()
}

Conn is interface

func Connect

func Connect(config *Config) Conn

Connect is a function to connect redis server and return the conn.

type DB

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

DB is redis db.

type Query

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

Query is struct.

func (*Query) FormatCommand

func (q *Query) FormatCommand(command string, args ...string)

FormatCommand is a function

type RedisPool

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

RedisPool is pool of redis client.

func NewRedisPool

func NewRedisPool(config *Config, size int) *RedisPool

NewRedisPool create new redis conn pool.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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