resp

package
v0.0.0-...-ebd0b0f Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2014 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package resp implements the REdis Serialization Protocol with the particular aim to communicate with Redis. See http://redis.io/topics/protocol for more information.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidResponse = errors.New("invalid response")
	ErrInvalidType     = errors.New("wrong redis type requested")
)

RESP errors

Functions

This section is empty.

Types

type Array

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

Array contains a sequence of RESP items.

func (*Array) Len

func (r *Array) Len() int

Len returns the total number of items in the Array.

func (*Array) Next

func (r *Array) Next() *RESP

Next returns the next RESP item in the Array.

func (*Array) String

func (r *Array) String() string

String returns a string representation of r. It consumes all of r's elements.

type RESP

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

RESP reads successive values in REdis Serialization Protocol. Values may be read by the method for their correct type. While type can be checked as many times as the caller wishes, each value may only be read once.

func New

func New(r io.Reader) *RESP

New creates a new RESP value from the given reader.

func (*RESP) Array

func (r *RESP) Array() (*Array, error)

Array returns a channel on which callers can receive successive elements of the RESP array.

func (*RESP) BulkString

func (r *RESP) BulkString() (io.Reader, error)

BulkString returns the value of a RESP as a reader.

func (*RESP) Error

func (r *RESP) Error() error

Error returns the value of a RESP as an error

func (*RESP) Int

func (r *RESP) Int() (int64, error)

Int returns the value of a RESP as an integer.

func (*RESP) SimpleString

func (r *RESP) SimpleString() (string, error)

SimpleString returns the value of a RESP as a simple string

func (*RESP) String

func (r *RESP) String() string

String returns a string representation of r. It consumes the content.

func (*RESP) Type

func (r *RESP) Type() RedisType

Type determines the redis type of a RESP.

type RedisType

type RedisType int

RedisType represents one of the five types RESP values may take or it is unknown or invalid.

const (
	UnknownType RedisType = iota
	InvalidType
	SimpleStringType
	ErrorType
	IntegerType
	BulkStringType
	ArrayType
	NullType
)

RESP types

func (RedisType) String

func (r RedisType) String() string

String returns a string representation of r.

Jump to

Keyboard shortcuts

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