Class: Redis::PipelinedConnection

Inherits:
Object
  • Object
show all
Includes:
Commands
Defined in:
lib/redis/pipeline.rb

Direct Known Subclasses

MultiConnection

Constant Summary

Constants included from Commands

Commands::Boolify, Commands::BoolifySet, Commands::Floatify, Commands::FloatifyPairs, Commands::Hashify, Commands::HashifyClusterNodeInfo, Commands::HashifyClusterNodes, Commands::HashifyClusterSlaves, Commands::HashifyClusterSlots, Commands::HashifyInfo, Commands::HashifyStreamAutoclaim, Commands::HashifyStreamAutoclaimJustId, Commands::HashifyStreamEntries, Commands::HashifyStreamPendingDetails, Commands::HashifyStreamPendings, Commands::HashifyStreams, Commands::Noop, Commands::Pairify

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Commands

#call, #sentinel

Methods included from Commands::Transactions

#discard, #exec, #unwatch, #watch

Methods included from Commands::Strings

#append, #decr, #decrby, #get, #getdel, #getex, #getrange, #getset, #incr, #incrby, #incrbyfloat, #mapped_mget, #mapped_mset, #mapped_msetnx, #mget, #mset, #msetnx, #psetex, #set, #setex, #setnx, #setrange, #strlen

Methods included from Commands::Streams

#xack, #xadd, #xautoclaim, #xclaim, #xdel, #xgroup, #xinfo, #xlen, #xpending, #xrange, #xread, #xreadgroup, #xrevrange, #xtrim

Methods included from Commands::SortedSets

#bzmpop, #bzpopmax, #bzpopmin, #zadd, #zcard, #zcount, #zdiff, #zdiffstore, #zincrby, #zinter, #zinterstore, #zlexcount, #zmpop, #zmscore, #zpopmax, #zpopmin, #zrandmember, #zrange, #zrangebylex, #zrangebyscore, #zrangestore, #zrank, #zrem, #zremrangebyrank, #zremrangebyscore, #zrevrange, #zrevrangebylex, #zrevrangebyscore, #zrevrank, #zscan, #zscan_each, #zscore, #zunion, #zunionstore

Methods included from Commands::Sets

#sadd, #sadd?, #scard, #sdiff, #sdiffstore, #sinter, #sinterstore, #sismember, #smembers, #smismember, #smove, #spop, #srandmember, #srem, #srem?, #sscan, #sscan_each, #sunion, #sunionstore

Methods included from Commands::Server

#bgrewriteaof, #bgsave, #client, #config, #dbsize, #debug, #flushall, #flushdb, #info, #lastsave, #monitor, #save, #shutdown, #slaveof, #slowlog, #sync, #time

Methods included from Commands::Scripting

#eval, #evalsha, #script

Methods included from Commands::Pubsub

#psubscribe, #psubscribe_with_timeout, #publish, #pubsub, #punsubscribe, #spublish, #ssubscribe, #ssubscribe_with_timeout, #subscribe, #subscribe_with_timeout, #subscribed?, #sunsubscribe, #unsubscribe

Methods included from Commands::Lists

#blmove, #blmpop, #blpop, #brpop, #brpoplpush, #lindex, #linsert, #llen, #lmove, #lmpop, #lpop, #lpush, #lpushx, #lrange, #lrem, #lset, #ltrim, #rpop, #rpoplpush, #rpush, #rpushx

Methods included from Commands::Keys

#copy, #del, #dump, #exists, #exists?, #expire, #expireat, #expiretime, #keys, #migrate, #move, #object, #persist, #pexpire, #pexpireat, #pexpiretime, #pttl, #randomkey, #rename, #renamenx, #restore, #scan, #scan_each, #sort, #ttl, #type, #unlink

Methods included from Commands::HyperLogLog

#pfadd, #pfcount, #pfmerge

Methods included from Commands::Hashes

#hdel, #hexists, #hget, #hgetall, #hincrby, #hincrbyfloat, #hkeys, #hlen, #hmget, #hmset, #hrandfield, #hscan, #hscan_each, #hset, #hsetnx, #hvals, #mapped_hmget, #mapped_hmset

Methods included from Commands::Geo

#geoadd, #geodist, #geohash, #geopos, #georadius, #georadiusbymember

Methods included from Connection

drivers

Methods included from Commands::Cluster

#asking, #cluster

Methods included from Commands::Bitmaps

#bitcount, #bitop, #bitpos, #getbit, #setbit

Constructor Details

#initialize(pipeline, futures = [], exception: true) ⇒ PipelinedConnection

Returns a new instance of PipelinedConnection.



9
10
11
12
13
# File 'lib/redis/pipeline.rb', line 9

def initialize(pipeline, futures = [], exception: true)
  @pipeline = pipeline
  @futures = futures
  @exception = exception
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Redis::Commands

Instance Attribute Details

#dbObject

Returns the value of attribute db.



7
8
9
# File 'lib/redis/pipeline.rb', line 7

def db
  @db
end

Instance Method Details

#multi {|transaction| ... } ⇒ Object

Yields:

  • (transaction)


21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/redis/pipeline.rb', line 21

def multi
  transaction = MultiConnection.new(@pipeline, @futures)
  send_command([:multi])
  size = @futures.size
  yield transaction
  multi_future = MultiFuture.new(@futures[size..-1])
  @pipeline.call_v([:exec]) do |result|
    multi_future._set(result)
  end
  @futures << multi_future
  multi_future
end

#pipelined {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:



17
18
19
# File 'lib/redis/pipeline.rb', line 17

def pipelined
  yield self
end