Class: VertxRedis::Redis
- Inherits:
-
Object
- Object
- VertxRedis::Redis
- Includes:
- Vertx::ReadStream
- Defined in:
- /Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-redis/redis.rb
Overview
A simple Redis client.
Constant Summary
- @@j_api_type =
Object.new
Class Method Summary (collapse)
- + (Boolean) accept?(obj)
-
+ (::VertxRedis::Redis) create_client(param_1 = nil, param_2 = nil)
Connect to redis, the onConnect will get the Redis instance.
- + (Object) j_api_type
- + (Object) j_class
- + (Object) unwrap(obj)
- + (Object) wrap(obj)
Instance Method Summary (collapse)
-
- (self) batch(commands = nil) { ... }
Sends a list of commands in a single IO operation, this prevents any inter twinning to happen from other client users.
- - (void) close
-
- (self) connect { ... }
Connects to the redis server.
-
- (self) end_handler { ... }
Set an end handler.
-
- (self) exception_handler { ... }
Set an exception handler on the read stream.
-
- (self) fetch(amount = nil)
Fetch the specified amount of elements.
-
- (self) handler { ... }
Set a data handler.
-
- (self) pause
Pause the ReadStream, it sets the buffer in fetch mode and clears the actual demand.
-
- (::Vertx::Pipe) pipe
Pause this stream and return a to transfer the elements of this stream to a destination .
-
- (void) pipe_to(dst = nil) { ... }
Pipe this ReadStream to the WriteStream.
-
- (self) resume
Resume reading, and sets the buffer in flowing mode.
-
- (self) send(command = nil) { ... }
Send the given command to the redis server or cluster.
-
- (String) socket_address
Returns the address associated with this client.
Class Method Details
+ (Boolean) accept?(obj)
25 26 27 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-redis/redis.rb', line 25 def @@j_api_type.accept?(obj) obj.class == Redis end |
+ (::VertxRedis::Redis) createClient(vertx, address) + (::VertxRedis::Redis) createClient(vertx, options)
Connect to redis, the
onConnect will get the VertxRedis::Redis instance.
73 74 75 76 77 78 79 80 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-redis/redis.rb', line 73 def self.create_client(param_1=nil,param_2=nil) if param_1.class.method_defined?(:j_del) && param_2.class == String && !block_given? return ::Vertx::Util::Utils.safe_create(Java::IoVertxRedisClient::Redis.java_method(:createClient, [Java::IoVertxCore::Vertx.java_class,Java::java.lang.String.java_class]).call(param_1.j_del,param_2),::VertxRedis::Redis) elsif param_1.class.method_defined?(:j_del) && param_2.class == Hash && !block_given? return ::Vertx::Util::Utils.safe_create(Java::IoVertxRedisClient::Redis.java_method(:createClient, [Java::IoVertxCore::Vertx.java_class,Java::IoVertxRedisClient::RedisOptions.java_class]).call(param_1.j_del,Java::IoVertxRedisClient::RedisOptions.new(::Vertx::Util::Utils.to_json_object(param_2))),::VertxRedis::Redis) end raise ArgumentError, "Invalid arguments when calling create_client(#{param_1},#{param_2})" end |
+ (Object) j_api_type
34 35 36 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-redis/redis.rb', line 34 def self.j_api_type @@j_api_type end |
+ (Object) j_class
37 38 39 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-redis/redis.rb', line 37 def self.j_class Java::IoVertxRedisClient::Redis.java_class end |
+ (Object) unwrap(obj)
31 32 33 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-redis/redis.rb', line 31 def @@j_api_type.unwrap(obj) obj.j_del end |
+ (Object) wrap(obj)
28 29 30 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-redis/redis.rb', line 28 def @@j_api_type.wrap(obj) Redis.new(obj) end |
Instance Method Details
- (self) batch(commands = nil) { ... }
Sends a list of commands in a single IO operation, this prevents any inter twinning to happen from other
client users.
171 172 173 174 175 176 177 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-redis/redis.rb', line 171 def batch(commands=nil) if commands.class == Array && true @j_del.java_method(:batch, [Java::JavaUtil::List.java_class,Java::IoVertxCore::Handler.java_class]).call(commands.map { |element| element.j_del },(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ar.result.to_a.map { |elt| ::Vertx::Util::Utils.safe_create(elt,::VertxRedis::Response) } : nil) } unless !block_given?)) return self end raise ArgumentError, "Invalid arguments when calling batch(#{commands})" end |
- (void) close
This method returns an undefined value.
187 188 189 190 191 192 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-redis/redis.rb', line 187 def close if !block_given? return @j_del.java_method(:close, []).call() end raise ArgumentError, "Invalid arguments when calling close()" end |
- (self) connect { ... }
Connects to the redis server.
84 85 86 87 88 89 90 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-redis/redis.rb', line 84 def connect if true @j_del.java_method(:connect, [Java::IoVertxCore::Handler.java_class]).call((Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ::Vertx::Util::Utils.safe_create(ar.result,::VertxRedis::Redis) : nil) } unless !block_given?)) return self end raise ArgumentError, "Invalid arguments when calling connect()" end |
- (self) end_handler { ... }
Set an end handler. Once the stream has ended, and there is no more data to be read, this handler will be called.
148 149 150 151 152 153 154 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-redis/redis.rb', line 148 def end_handler if true @j_del.java_method(:endHandler, [Java::IoVertxCore::Handler.java_class]).call(Proc.new { yield unless !block_given? }) return self end raise ArgumentError, "Invalid arguments when calling end_handler()" end |
- (self) exception_handler { ... }
Set an exception handler on the read stream.
94 95 96 97 98 99 100 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-redis/redis.rb', line 94 def exception_handler if true @j_del.java_method(:exceptionHandler, [Java::IoVertxCore::Handler.java_class]).call((Proc.new { |event| yield(::Vertx::Util::Utils.from_throwable(event)) unless !block_given? })) return self end raise ArgumentError, "Invalid arguments when calling exception_handler()" end |
- (self) fetch(amount = nil)
Fetch the specified
amount of elements. If the ReadStream has been paused, reading will
recommence with the specified amount of items, otherwise the specified amount will
be added to the current stream demand.
138 139 140 141 142 143 144 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-redis/redis.rb', line 138 def fetch(amount=nil) if amount.class == Fixnum && !block_given? @j_del.java_method(:fetch, [Java::long.java_class]).call(amount) return self end raise ArgumentError, "Invalid arguments when calling fetch(#{amount})" end |
- (self) handler { ... }
Set a data handler. As data is read, the handler will be called with the data.
104 105 106 107 108 109 110 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-redis/redis.rb', line 104 def handler if true @j_del.java_method(:handler, [Java::IoVertxCore::Handler.java_class]).call((Proc.new { |event| yield(::Vertx::Util::Utils.safe_create(event,::VertxRedis::Response)) unless !block_given? })) return self end raise ArgumentError, "Invalid arguments when calling handler()" end |
- (self) pause
Pause the
ReadStream, it sets the buffer in fetch mode and clears the actual demand.
While it's paused, no data will be sent to the data handler.
115 116 117 118 119 120 121 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-redis/redis.rb', line 115 def pause if !block_given? @j_del.java_method(:pause, []).call() return self end raise ArgumentError, "Invalid arguments when calling pause()" end |
- (::Vertx::Pipe) pipe
Pause this stream and return a to transfer the elements of this stream to a destination .
The stream will be resumed when the pipe will be wired to a
WriteStream.
44 45 46 47 48 49 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-redis/redis.rb', line 44 def pipe if !block_given? return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:pipe, []).call(),::Vertx::Pipe,::VertxRedis::Response.j_api_type) end raise ArgumentError, "Invalid arguments when calling pipe()" end |
- (void) pipe_to(dst = nil) { ... }
This method returns an undefined value.
Pipe thisReadStream to the WriteStream.
Elements emitted by this stream will be written to the write stream until this stream ends or fails.
Once this stream has ended or failed, the write stream will be ended and the handler will be
called with the result.
59 60 61 62 63 64 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-redis/redis.rb', line 59 def pipe_to(dst=nil) if dst.class.method_defined?(:j_del) && true return @j_del.java_method(:pipeTo, [Java::IoVertxCoreStreams::WriteStream.java_class,Java::IoVertxCore::Handler.java_class]).call(dst.j_del,(Proc.new { |ar| yield(ar.failed ? ar.cause : nil) } unless !block_given?)) end raise ArgumentError, "Invalid arguments when calling pipe_to(#{dst})" end |
- (self) resume
Resume reading, and sets the buffer in
flowing mode.
If the ReadStream has been paused, reading will recommence on it.
126 127 128 129 130 131 132 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-redis/redis.rb', line 126 def resume if !block_given? @j_del.java_method(:resume, []).call() return self end raise ArgumentError, "Invalid arguments when calling resume()" end |
- (self) send(command = nil) { ... }
Send the given command to the redis server or cluster.
159 160 161 162 163 164 165 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-redis/redis.rb', line 159 def send(command=nil) if command.class.method_defined?(:j_del) && true @j_del.java_method(:send, [Java::IoVertxRedisClient::Request.java_class,Java::IoVertxCore::Handler.java_class]).call(command.j_del,(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ::Vertx::Util::Utils.safe_create(ar.result,::VertxRedis::Response) : nil) } unless !block_given?)) return self end raise ArgumentError, "Invalid arguments when calling send(#{command})" end |
- (String) socket_address
Returns the address associated with this client.
180 181 182 183 184 185 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-redis/redis.rb', line 180 def socket_address if !block_given? return @j_del.java_method(:socketAddress, []).call() end raise ArgumentError, "Invalid arguments when calling socket_address()" end |