Ejemplo n.º 1
0
        public Task Save(string key, object value)
        {
            if (ConnectionReady())
            {
                return Connection.Strings.Increment(_database, MessageIdKey)
                    .Then(t =>
                              {
                                  var message = new ProtoMessage
                                                    {
                                                        Created = DateTime.Now,
                                                        SignalKey = key,
                                                        Id = t.Result,
                                                        Value = _serializer.Serialize(value)
                                                    };
                                  return _redisConnection.SortedSets.Add(_database,
                                                                         key,
                                                                         message.Serialize(),
                                                                         message.Id);
                              }).FastUnwrap();
            }

            throw new InvalidOperationException("Could not save message.  Redis connection failure.");
        }
Ejemplo n.º 2
0
 public Task Save(string key, object value)
 {
     return _redisConnection.Strings.Increment(_database, MessageIdKey)
         .ContinueWith(t =>
                           {
                               var message = new ProtoMessage
                                                 {
                                                     Created = DateTime.Now,
                                                     SignalKey = key,
                                                     Id = t.Result,
                                                     Value = _jsonSerializer.Stringify(value)
                                                 };
                               _redisConnection.SortedSets.Add(_database,
                                                               MessagesKey,
                                                               message.Serialize(),
                                                               message.Id);
                           });
 }