Class: Oxblood::Pipeline
- Inherits:
-
Object
- Object
- Oxblood::Pipeline
- Includes:
- Commands
- Defined in:
- lib/oxblood/pipeline.rb
Overview
Redis pipeling class. Commands won’t be send until #sync is called. Error responses won’t be raised and should be checked manually in the responses array.
Instance Attribute Summary collapse
-
#connection ⇒ Object
readonly
Returns the value of attribute connection.
Instance Method Summary collapse
-
#initialize(connection) ⇒ Pipeline
constructor
A new instance of Pipeline.
-
#sync ⇒ Array
Sends all commands at once and reads responses.
Methods included from Commands::Transactions
#discard, #exec, #multi, #unwatch, #watch
Methods included from Commands::SortedSets
#zadd, #zcard, #zcount, #zincrby, #zinterstore, #zlexcount, #zrange, #zrangebylex, #zrangebyscore, #zrank, #zrem, #zremrangebylex, #zremrangebyrank, #zremrangebyscore, #zrevrange, #zrevrangebylex, #zrevrangebyscore, #zrevrank, #zscan, #zscore, #zunionstore
Methods included from Commands::Scripting
#eval, #evalsha, #script_debug, #script_exists, #script_flush, #script_kill, #script_load
Methods included from Commands::Sets
#sadd, #scard, #sdiff, #sdiffstore, #sinter, #sinterstore, #sismember, #smembers, #smove, #spop, #srandmember, #srem, #sscan, #sunion, #sunionstore
Methods included from Commands::Lists
#blpop, #brpop, #brpoplpush, #lindex, #linsert, #llen, #lpop, #lpush, #lpushx, #lrange, #lrem, #lset, #ltrim, #rpop, #rpoplpush, #rpush, #rpushx
Methods included from Commands::Keys
#del, #dump, #exists, #expire, #expireat, #keys, #move, #object, #persist, #pexpire, #pexpireat, #pttl, #randomkey, #rename, #renamenx, #restore, #scan, #ttl, #type
Methods included from Commands::Server
#bgrewriteaof, #bgsave, #client_getname, #client_kill, #client_list, #client_pause, #client_setname, #command, #command_count, #command_getkeys, #command_info, #config_get, #config_resetstat, #config_rewrite, #config_set, #dbsize, #flushall, #flushdb, #info, #lastsave, #role, #save, #shutdown, #slaveof, #slowlog, #time
Methods included from Commands::Geo
#geoadd, #geodist, #geohash, #geopos, #georadius, #georadiusbymember
Methods included from Commands::Connection
#auth, #echo, #ping, #quit, #select
Methods included from Commands::Strings
#append, #bitcount, #bitop, #bitpos, #decr, #decrby, #get, #getbit, #getrange, #getset, #incr, #incrby, #incrbyfloat, #mget, #mset, #msetnx, #psetex, #set, #setbit, #setex, #setnx, #setrange, #strlen
Methods included from Commands::HyperLogLog
Methods included from Commands::Hashes
#hdel, #hexists, #hget, #hgetall, #hincrby, #hincrbyfloat, #hkeys, #hlen, #hmget, #hmset, #hscan, #hset, #hsetnx, #hstrlen, #hvals
Constructor Details
#initialize(connection) ⇒ Pipeline
Returns a new instance of Pipeline.
21 22 23 24 |
# File 'lib/oxblood/pipeline.rb', line 21 def initialize(connection) @connection = connection @commands = Array.new end |
Instance Attribute Details
#connection ⇒ Object (readonly)
Returns the value of attribute connection.
19 20 21 |
# File 'lib/oxblood/pipeline.rb', line 19 def connection @connection end |
Instance Method Details
#sync ⇒ Array
Sends all commands at once and reads responses
28 29 30 31 32 33 34 |
# File 'lib/oxblood/pipeline.rb', line 28 def sync serialized_commands = @commands.map { |c| Protocol.build_command(*c) } connection.socket.write(serialized_commands.join) Array.new(@commands.size) { connection.read_response } ensure @commands.clear end |