X-Git-Url: https://git.saurik.com/redis.git/blobdiff_plain/ed9b544e10b84cd43348ddfab7068b610a5df1f7..49128f0b9da725de992e427fa341a837bcc2991b:/doc/ReplyTypes.html diff --git a/doc/ReplyTypes.html b/doc/ReplyTypes.html index 18b4a640..9f60aecf 100644 --- a/doc/ReplyTypes.html +++ b/doc/ReplyTypes.html @@ -16,7 +16,7 @@
-ReplyTypes: Contents
  Redis Reply Types
  Status code reply
  Integer reply
  Bulk reply
  Multi bulk reply +ReplyTypes: Contents
  Redis Reply Types
  Status code reply
  Error reply
  Integer reply
  Bulk reply
  Multi bulk reply

ReplyTypes

@@ -27,14 +27,12 @@

Redis Reply Types

Redis commands can reply to the client with four different kind of replies, you can find the protocol level specification of this replies in the Redis Protocol Specification. This page is instead an higher level description of the four types of replies from the point of view of the final user.

Status code reply

-Status code replies are in the form of a +OK from the server, or a -ERR followed by an error string. At the protocol level this replies are sent as a single line. Client libraries should return true on OK, and should raise an exception in form of an error that stops the execution of the program on ERR replies from server, because this kind of replies are used by operations that usually fails because of a programming error, an inconsistent DB, and so on.

Integer reply

-At protocol level integer replies are single line replies in form of a decimal singed number. Redis commands returning true or false will use an integer reply and "1" and "0" as replies. A negative value in an integer reply is used to signal an error by all the commands, with the exception of INCR/INCRBY/DECR/DECRBY where negative return values are allowed (this command never fails).

All the integer replies using negative values to return errors will use the same values to signal the same errors: - -1 key not found - -2 key contains a value of the wrong type - -3 source object and destination object are the same - -4 out of range argument

Integer replies are usually passed by client libraries as integer values. On negative integer reply an exception should be raised (excluding the INCR family commands).

Bulk reply

-A bulk reply is a binary-safe reply that is used to return a single string value (string is not limited to alphanumerical strings, it may contain binary data of any kind). Client libraries will usually return a string as return value of Redis commands returning bulk replies. There is a special bulk reply that signal that the element does not exist. When this happens the client library should return 'nil', 'false', or some other special element that can be distinguished by an empty string.

Multi bulk reply

-While a bulk reply returns a single string value, multi bulk replies are used to return multiple values: lists, sets, and so on. Elements of a bulk reply can be missing (-1 length count at protocol level). Client libraries should return 'nil' or 'false' in order to make this elements distinguishable from empty strings. Client libraries should return multi bulk replies that are about ordered elements like list ranges as lists, and bulk replies about sets as hashes. +Status code replies are single line strings having the + character as first byte. The string to return to the client is simply verything that follows the first + character. For example the PING command returns +PONG, that is the string "PONG".

Error reply

+This is like a status code reply but the first character is - instead of +. The client library should raise an error for error replies and stop the execution of the program if the exception is not trapped, showing the error message (everything following the first - character). An example of error is "-Error no such key" or "-foobar". Note that error replies will not collide with negative integer replies since integer replies are prefixed with the : character.

Integer reply

+At protocol level integer replies are single line replies in form of a decimal singed number prefixed by a : character. For example :10 is an integer reply. Redis commands returning true or false will use an integer reply with 0 or 1 as values where 0 is false and 1 is true.

Integer replies are usually passed by client libraries as integer values.

Bulk reply

+A bulk reply is a binary-safe reply that is used to return a binary safe single string value (string is not limited to alphanumerical strings, it may contain binary data of any kind). Client libraries will usually return a string as return value of Redis commands returning bulk replies. There is a special bulk reply that signal that the element does not exist. When this happens the client library should return 'nil', 'false', or some other special element that can be distinguished by an empty string.

Multi bulk reply

+While a bulk reply returns a single string value, multi bulk replies are used to return multiple values: lists, sets, and so on. Elements of a bulk reply can be missing. Client libraries should return 'nil' or 'false' in order to make this elements distinguishable from empty strings. Client libraries should return multi bulk replies that are about ordered elements like list ranges as lists, and bulk replies about sets as hashes or Sets if the implementation language has a Set type. +