Dart Documentationredis_protocol_transformerRedisReply

RedisReply abstract class

Base class for redis replies.

Every time a new redis reply is received, this class is instantiated, and returned with the corresponding data.

abstract class RedisReply {

 /// A reply type
 static const int STATUS = RedisProtocolTransformer.PLUS;

 /// A reply type
 static const int ERROR = RedisProtocolTransformer.DASH;

 /// A reply type
 static const int INTEGER = RedisProtocolTransformer.COLON;

 /// A reply type
 static const int BULK = RedisProtocolTransformer.DOLLAR;

 /// A reply type
 static const int MULTI_BULK = RedisProtocolTransformer.ASTERIX;


 /// Specifies if this reply has been fully received.
 bool get done;


 /// Consumes the data and returns the uncosumed data if any, null otherwise.
 List<int> _consumeData(List<int> data);

 /// Default constructor does nothing.
 RedisReply();

 /**
  *  Factory constructor for [RedisReply] implementations.
  *
  *  Valid replies are:
  *
  *  - [ErrorReply] (`"-"`)
  *  - [StatusReply] (`"+"`)
  *  - [IntegerReply] (`":"`)
  *  - [BulkReply] (`"$"`)
  *  - [MultiBulkReply] (`"*"`)
  */
 factory RedisReply.fromType(int replyTypeChar) {

   // Now instantiate the correct RedisReply
   switch (replyTypeChar) {
     case RedisReply.STATUS:     return new StatusReply();
     case RedisReply.ERROR:      return new ErrorReply();
     case RedisReply.INTEGER:    return new IntegerReply();
     case RedisReply.BULK:       return new BulkReply();
     case RedisReply.MULTI_BULK: return new MultiBulkReply();
     default:
       throw new InvalidRedisResponseError("The type character was incorrect (${new String.fromCharCode(replyTypeChar)}).");
   }

 }

}

Subclasses

BulkReply, MultiBulkReply

Static Properties

const int BULK #

A reply type

static const int BULK = RedisProtocolTransformer.DOLLAR

const int ERROR #

A reply type

static const int ERROR = RedisProtocolTransformer.DASH

const int INTEGER #

A reply type

static const int INTEGER = RedisProtocolTransformer.COLON

const int MULTI_BULK #

A reply type

static const int MULTI_BULK = RedisProtocolTransformer.ASTERIX

const int STATUS #

A reply type

static const int STATUS = RedisProtocolTransformer.PLUS

Constructors

new RedisReply() #

Default constructor does nothing.

RedisReply();

factory RedisReply.fromType(int replyTypeChar) #

Factory constructor for RedisReply implementations.

Valid replies are:

factory RedisReply.fromType(int replyTypeChar) {

 // Now instantiate the correct RedisReply
 switch (replyTypeChar) {
   case RedisReply.STATUS:     return new StatusReply();
   case RedisReply.ERROR:      return new ErrorReply();
   case RedisReply.INTEGER:    return new IntegerReply();
   case RedisReply.BULK:       return new BulkReply();
   case RedisReply.MULTI_BULK: return new MultiBulkReply();
   default:
     throw new InvalidRedisResponseError("The type character was incorrect (${new String.fromCharCode(replyTypeChar)}).");
 }

}

Properties

final bool done #

Specifies if this reply has been fully received.

bool get done;