public static ToBytes ( IList |
||
messages | IList |
|
return | byte[] |
protected override Task Send(int streamIndex, IList <Message> messages) { return(_connection.ScriptEvaluateAsync( _db, @"local newId = redis.call('INCR', KEYS[1]) local payload = newId .. ' ' .. ARGV[1] redis.call('PUBLISH', KEYS[1], payload) return {newId, ARGV[1], payload}", _key, RedisMessage.ToBytes(messages))); }
protected override Task Send(int streamIndex, IList <Message> messages) { var keys = new string[] { _key }; var arguments = new object[] { RedisMessage.ToBytes(messages) }; return(_connection.Scripting.Eval( _db, @"local newId = redis.call('INCR', KEYS[1]) local payload = newId .. ' ' .. ARGV[1] return redis.call('PUBLISH', KEYS[1], payload)", keys, arguments)); }
protected override Task Send(int streamIndex, IList <Message> messages) { var context = new SendContext(_key, messages, _connection); // Increment the channel number return(_connection.Strings.Increment(_db, _key) .Then((id, ctx) => { byte[] data = RedisMessage.ToBytes(id, ctx.Messages); return ctx.Connection.Publish(ctx.Key, data); }, context)); }
private Task <bool> ExecuteTransaction(RedisTransaction transaction, long?oldId, IList <Message> messages) { _trace.TraceVerbose("ExecuteTransaction({0})", oldId); // New target id long newId = (oldId ?? 0) + 1; // TODO: Don't do this everytime byte[] data = RedisMessage.ToBytes(newId, messages); // These don't need to be observed transaction.AddCondition(Condition.KeyEquals(_db, _key, oldId)); transaction.Strings.Increment(_db, _key); transaction.Publish(_key, data); // Execute the transaction return(transaction.Execute()); }