Class: Async::Redis::Client
- Inherits:
-
Object
- Object
- Async::Redis::Client
- Includes:
- Methods::Keys, Methods::Lists, Methods::Server, Methods::Strings
- Defined in:
- lib/async/redis/client.rb
Instance Attribute Summary collapse
-
#endpoint ⇒ Object
readonly
Returns the value of attribute endpoint.
-
#protocol ⇒ Object
readonly
Returns the value of attribute protocol.
Class Method Summary collapse
Instance Method Summary collapse
- #call(*arguments) ⇒ Object
- #close ⇒ Object
-
#initialize(endpoint = Redis.local_endpoint, protocol = Protocol::RESP, **options) ⇒ Client
constructor
A new instance of Client.
- #multi(&block) ⇒ Object
- #publish(channel, message) ⇒ Object
- #subscribe(*channels) ⇒ Object
Methods included from Methods::Server
Methods included from Methods::Lists
#blpop, #brpop, #brpoplpush, #lindex, #linsert, #llen, #lpop, #lpush, #lpushx, #lrange, #lrem, #lset, #ltrim, #rpop, #rpoplpush, #rpush, #rpushx
Methods included from Methods::Keys
#del, #dump, #exists, #expire, #expireat, #keys, #migrate, #move, #object, #persist, #pexpire, #pexpireat, #pttl, #randomkey, #rename, #renamenx, #restore, #scan, #sort, #touch, #ttl, #type, #unlink, #wait
Methods included from Methods::Strings
#append, #bitcount, #decr, #decrby, #get, #getbit, #getrange, #getset, #incr, #incrby, #incrbyfloat, #mget, #mset, #msetnx, #psetex, #set, #setbit, #setex, #setnx, #setrange, #strlen
Constructor Details
#initialize(endpoint = Redis.local_endpoint, protocol = Protocol::RESP, **options) ⇒ Client
Returns a new instance of Client.
45 46 47 48 49 50 |
# File 'lib/async/redis/client.rb', line 45 def initialize(endpoint = Redis.local_endpoint, protocol = Protocol::RESP, **) @endpoint = endpoint @protocol = protocol @pool = connect(**) end |
Instance Attribute Details
#endpoint ⇒ Object (readonly)
Returns the value of attribute endpoint.
52 53 54 |
# File 'lib/async/redis/client.rb', line 52 def endpoint @endpoint end |
#protocol ⇒ Object (readonly)
Returns the value of attribute protocol.
53 54 55 |
# File 'lib/async/redis/client.rb', line 53 def protocol @protocol end |
Class Method Details
.open(*args, &block) ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/async/redis/client.rb', line 55 def self.open(*args, &block) client = self.new(*args) return client unless block_given? begin yield client ensure client.close end end |
Instance Method Details
#call(*arguments) ⇒ Object
99 100 101 102 103 104 |
# File 'lib/async/redis/client.rb', line 99 def call(*arguments) @pool.acquire do |connection| connection.write_request(arguments) return connection.read_response end end |
#close ⇒ Object
67 68 69 |
# File 'lib/async/redis/client.rb', line 67 def close @pool.close end |
#multi(&block) ⇒ Object
87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/async/redis/client.rb', line 87 def multi(&block) context = Context::Multi.new(@pool) return context unless block_given? begin yield context ensure context.close end end |
#publish(channel, message) ⇒ Object
71 72 73 |
# File 'lib/async/redis/client.rb', line 71 def publish(channel, ) call('PUBLISH', channel, ) end |