Browse Source

Update doc to new and improved Redis terminolgy

Gary Burd 11 years ago
parent
commit
deb35f4cb1
4 changed files with 36 additions and 38 deletions
  1. 2 2
      redis/conn.go
  2. 4 4
      redis/doc.go
  3. 15 15
      redis/reply.go
  4. 15 17
      redis/scan.go

+ 2 - 2
redis/conn.go

@@ -206,7 +206,7 @@ func (c *conn) readLine() ([]byte, error) {
 	return p[:i], nil
 }
 
-// parseLen parses bulk and multi-bulk lengths.
+// parseLen parses bulk string and array lengths.
 func parseLen(p []byte) (int, error) {
 	if len(p) == 0 {
 		return -1, errors.New("redigo: malformed length")
@@ -301,7 +301,7 @@ func (c *conn) readReply() (interface{}, error) {
 		if line, err := c.readLine(); err != nil {
 			return nil, err
 		} else if len(line) != 0 {
-			return nil, errors.New("redigo: bad bulk format")
+			return nil, errors.New("redigo: bad bulk string format")
 		}
 		return p, nil
 	case '*':

+ 4 - 4
redis/doc.go

@@ -55,9 +55,9 @@
 //  Redis type              Go type
 //  error                   redis.Error
 //  integer                 int64
-//  status                  string
-//  bulk                    []byte or nil if value not present.
-//  multi-bulk              []interface{} or nil if value not present.
+//  simple string           string
+//  bulk string             []byte or nil if value not present.
+//  array                   []interface{} or nil if value not present.
 //
 // Use type assertions or the reply helper functions to convert from
 // interface{} to the specific Go type for the command result.
@@ -153,7 +153,7 @@
 //      // handle error return from c.Do or type conversion error.
 //  }
 //
-// The Scan function converts elements of a multi-bulk reply to Go types:
+// The Scan function converts elements of a array reply to Go types:
 //
 //  var value1 int
 //  var value2 string

+ 15 - 15
redis/reply.go

@@ -29,7 +29,7 @@ var ErrNil = errors.New("redigo: nil returned")
 //
 //  Reply type    Result
 //  integer       int(reply), nil
-//  bulk          parsed reply, nil
+//  bulk string   parsed reply, nil
 //  nil           0, ErrNil
 //  other         0, error
 func Int(reply interface{}, err error) (int, error) {
@@ -60,7 +60,7 @@ func Int(reply interface{}, err error) (int, error) {
 //
 //  Reply type    Result
 //  integer       reply, nil
-//  bulk          parsed reply, nil
+//  bulk string   parsed reply, nil
 //  nil           0, ErrNil
 //  other         0, error
 func Int64(reply interface{}, err error) (int64, error) {
@@ -86,7 +86,7 @@ func Int64(reply interface{}, err error) (int64, error) {
 // the reply to an int as follows:
 //
 //  Reply type    Result
-//  bulk          parsed reply, nil
+//  bulk string   parsed reply, nil
 //  nil           0, ErrNil
 //  other         0, error
 func Float64(reply interface{}, err error) (float64, error) {
@@ -110,8 +110,8 @@ func Float64(reply interface{}, err error) (float64, error) {
 // reply to a string as follows:
 //
 //  Reply type      Result
-//  bulk            string(reply), nil
-//  status          reply, nil
+//  bulk string     string(reply), nil
+//  simple string   reply, nil
 //  nil             "",  ErrNil
 //  other           "",  error
 func String(reply interface{}, err error) (string, error) {
@@ -136,8 +136,8 @@ func String(reply interface{}, err error) (string, error) {
 // the reply to a slice of bytes as follows:
 //
 //  Reply type      Result
-//  bulk            reply, nil
-//  status          []byte(reply), nil
+//  bulk string     reply, nil
+//  simple string   []byte(reply), nil
 //  nil             nil, ErrNil
 //  other           nil, error
 func Bytes(reply interface{}, err error) ([]byte, error) {
@@ -163,7 +163,7 @@ func Bytes(reply interface{}, err error) ([]byte, error) {
 //
 //  Reply type      Result
 //  integer         value != 0, nil
-//  bulk            strconv.ParseBool(reply)
+//  bulk string     strconv.ParseBool(reply)
 //  nil             false, ErrNil
 //  other           false, error
 func Bool(reply interface{}, err error) (bool, error) {
@@ -186,12 +186,12 @@ func Bool(reply interface{}, err error) (bool, error) {
 // MultiBulk is deprecated. Use Values.
 func MultiBulk(reply interface{}, err error) ([]interface{}, error) { return Values(reply, err) }
 
-// Values is a helper that converts a multi-bulk command reply to a
-// []interface{}. If err is not equal to nil, then Values returns nil, err.
-// Otherwise, Multi converts the reply as follows:
+// Values is a helper that converts an array command reply to a []interface{}.
+// If err is not equal to nil, then Values returns nil, err. Otherwise, Values
+// converts the reply as follows:
 //
 //  Reply type      Result
-//  multi-bulk      reply, nil
+//  array           reply, nil
 //  nil             nil, ErrNil
 //  other           nil, error
 func Values(reply interface{}, err error) ([]interface{}, error) {
@@ -209,9 +209,9 @@ func Values(reply interface{}, err error) ([]interface{}, error) {
 	return nil, fmt.Errorf("redigo: unexpected type for Values, got type %T", reply)
 }
 
-// Strings is a helper that converts a multi-bulk command reply to a []string.
-// If err is not equal to nil, then Strings returns nil, err.  If one if the
-// multi-bulk items is not a bulk value or nil, then Strings returns an error.
+// Strings is a helper that converts an array command reply to a []string. If
+// err is not equal to nil, then Strings returns nil, err. If one if the array
+// items is not a bulk string or nil, then Strings returns an error.
 func Strings(reply interface{}, err error) ([]string, error) {
 	if err != nil {
 		return nil, err

+ 15 - 17
redis/scan.go

@@ -188,22 +188,21 @@ func convertAssign(d interface{}, s interface{}) (err error) {
 	return
 }
 
-// Scan copies from the multi-bulk src to the values pointed at by dest.
+// Scan copies from src to the values pointed at by dest.
 //
 // The values pointed at by dest must be an integer, float, boolean, string,
 // []byte, interface{} or slices of these types. Scan uses the standard strconv
-// package to convert bulk values to numeric and boolean types.
+// package to convert bulk strings to numeric and boolean types.
 //
 // If a dest value is nil, then the corresponding src value is skipped.
 //
-// If the multi-bulk value is nil, then the corresponding dest value is not
-// modified.
+// If a src element is nil, then the corresponding dest value is not modified.
 //
 // To enable easy use of Scan in a loop, Scan returns the slice of src
 // following the copied values.
 func Scan(src []interface{}, dest ...interface{}) ([]interface{}, error) {
 	if len(src) < len(dest) {
-		return nil, errors.New("redigo: Scan multibulk short")
+		return nil, errors.New("redigo: Scan array short")
 	}
 	var err error
 	for i, d := range dest {
@@ -320,8 +319,8 @@ func structSpecForType(t reflect.Type) *structSpec {
 
 var errScanStructValue = errors.New("redigo: ScanStruct value must be non-nil pointer to a struct")
 
-// ScanStruct scans a multi-bulk src containing alternating names and values to
-// a struct. The HGETALL and CONFIG GET commands return replies in this format.
+// ScanStruct scans alternating names and values from src to a struct. The
+// HGETALL and CONFIG GET commands return replies in this format.
 //
 // ScanStruct uses exported field names to match values in the response. Use
 // 'redis' field tag to override the name:
@@ -330,12 +329,11 @@ var errScanStructValue = errors.New("redigo: ScanStruct value must be non-nil po
 //
 // Fields with the tag redis:"-" are ignored.
 //
-// Integer, float boolean string and []byte fields are supported. Scan uses
-// the standard strconv package to convert bulk values to numeric and boolean
-// types.
+// Integer, float boolean string and []byte fields are supported. Scan uses the
+// standard strconv package to convert bulk string values to numeric and
+// boolean types.
 //
-// If the multi-bulk value is nil, then the corresponding field is not
-// modified.
+// If a src element is nil, then the corresponding field is not modified.
 func ScanStruct(src []interface{}, dest interface{}) error {
 	d := reflect.ValueOf(dest)
 	if d.Kind() != reflect.Ptr || d.IsNil() {
@@ -354,7 +352,7 @@ func ScanStruct(src []interface{}, dest interface{}) error {
 	for i := 0; i < len(src); i += 2 {
 		name, ok := src[i].([]byte)
 		if !ok {
-			return errors.New("redigo: ScanStruct key not a bulk value")
+			return errors.New("redigo: ScanStruct key not a bulk string value")
 		}
 		fs := ss.fieldSpec(name)
 		if fs == nil {
@@ -381,12 +379,12 @@ func ScanStruct(src []interface{}, dest interface{}) error {
 
 var (
 	errScanSliceValue = errors.New("redigo: ScanSlice dest must be non-nil pointer to a struct")
-	errScanSliceSrc   = errors.New("redigo: ScanSlice src element must be bulk or nil")
+	errScanSliceSrc   = errors.New("redigo: ScanSlice src element must be bulk string or nil")
 )
 
-// ScanSlice scans multi-bulk src to the slice pointed to by dest. The elements
-// the dest slice must be integer, float, boolean, string, struct or pointer to
-// struct values.
+// ScanSlice scans src to the slice pointed to by dest. The elements the dest
+// slice must be integer, float, boolean, string, struct or pointer to struct
+// values.
 //
 // Struct fields must be integer, float, boolean or string values. All struct
 // fields are used unless a subset is specified using fieldNames.