proto

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Nil      = "$-1\r\n"
	NilList  = "*-1\r\n"
	NilList2 = "*0\r\n"
)

Variables

View Source
var (
	ErrProtocol   = errors.New("unsupported protocol")
	ErrUnexpected = errors.New("not what you asked for")
)

Functions

func Array

func Array(args ...string) string

Array assembles the args in a list. Args should be raw redis commands. Example: Array(String("foo"), String("bar"))

func Error

func Error(s string) string

Error

func Float

func Float(n float64) string

Float

func Inline

func Inline(s string) string

Inline string

func Int

func Int(n int) string

Int

func Ints

func Ints(args ...int) string

Ints is a helper to build 1 dimensional int arrays.

func IsError

func IsError(s string) bool

func Map

func Map(args ...string) string

Map assembles the args in a map. Args should be raw redis commands. Must be an even number of arguments. Example: Map(String("foo"), String("bar"))

func Parse

func Parse(b string) (interface{}, error)

Parse into interfaces. `b` must contain exactly a single command (which can be nested).

func Push

func Push(args ...string) string

Push assembles the args for push-data. Args should be raw redis commands. Example: Push(String("foo"), String("bar"))

func Read

func Read(r *bufio.Reader) (string, error)

Read a single command, returning it raw. Used to read replies from redis. Understands RESP3 proto.

func ReadArray

func ReadArray(b string) ([]string, error)

Read an array, with all elements are the raw redis commands Also reads sets and maps.

func ReadError

func ReadError(b string) (string, error)

func ReadString

func ReadString(b string) (string, error)

func ReadStrings

func ReadStrings(b string) ([]string, error)

func Set

func Set(args ...string) string

Set assembles the args in a map. Args should be raw redis commands. Example: Set(String("foo"), String("bar"))

func String

func String(s string) string

Byte-safe string

func StringMap

func StringMap(args ...string) string

StringMap is is a wrapper to get a map of (bulk)strings.

func StringSet

func StringSet(args ...string) string

StringSet is is a wrapper to get a set of (bulk)strings.

func Strings

func Strings(args ...string) string

Strings is a helper to build 1 dimensional string arrays.

func Write

func Write(w io.Writer, cmd []string) error

Write a command in RESP3 proto. Used to write commands to redis. Currently only supports string arrays.

Types

type Client

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

func Dial

func Dial(addr string) (*Client, error)

func DialTLS

func DialTLS(addr string, cfg *tls.Config) (*Client, error)

func (*Client) Close

func (c *Client) Close() error

func (*Client) Do

func (c *Client) Do(cmd ...string) (string, error)

func (*Client) DoStrings

func (c *Client) DoStrings(cmd ...string) ([]string, error)

Do() + ReadStrings()

func (*Client) Read

func (c *Client) Read() (string, error)

Jump to

Keyboard shortcuts

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