Example #1
0
	"strconv"

	"gopkg.in/redis.v4/internal/errors"
)

const (
	ErrorReply  = '-'
	StatusReply = '+'
	IntReply    = ':'
	StringReply = '$'
	ArrayReply  = '*'
)

const defaultBufSize = 4096

var errScanNil = errors.RedisError("redis: Scan(nil)")

func Scan(b []byte, val interface{}) error {
	switch v := val.(type) {
	case nil:
		return errScanNil
	case *string:
		*v = string(b)
		return nil
	case *[]byte:
		*v = b
		return nil
	case *int:
		var err error
		*v, err = strconv.Atoi(string(b))
		return err
Example #2
0
func parseErrorValue(line []byte) error {
	return ierrors.RedisError(string(line[1:]))
}
Example #3
0
File: tx.go Project: ovh/tat
package redis

import (
	"errors"
	"fmt"

	"gopkg.in/redis.v4/internal"
	ierrors "gopkg.in/redis.v4/internal/errors"
	"gopkg.in/redis.v4/internal/pool"
	"gopkg.in/redis.v4/internal/proto"
)

// Redis transaction failed.
const TxFailedErr = ierrors.RedisError("redis: transaction failed")

var errDiscard = errors.New("redis: Discard can be used only inside Exec")

// Tx implements Redis transactions as described in
// http://redis.io/topics/transactions. It's NOT safe for concurrent use
// by multiple goroutines, because Exec resets list of watched keys.
// If you don't need WATCH it is better to use Pipeline.
type Tx struct {
	cmdable
	statefulCmdable
	baseClient

	cmds   []Cmder
	closed bool
}

var _ BaseCmdable = (*Tx)(nil)