Class: VertxRedis::RedisConnection
- Inherits:
-
Object
- Object
- VertxRedis::RedisConnection
- Includes:
- Vertx::ReadStream
- Defined in:
- /Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-redis/redis_connection.rb
Overview
A simple Redis client.
Constant Summary
- @@j_api_type =
Object.new
Class Method Summary (collapse)
- + (Boolean) accept?(obj)
- + (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
Closes the connection or returns to the pool.
- - (self) end_handler { ... }
- - (self) exception_handler { ... }
- - (self) fetch(amount = nil)
- - (self) handler { ... }
- - (self) pause
-
- (true, false) pending_queue_full?
Flag to notify if the pending message queue (commands in transit) is full.
-
- (::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
-
- (self) send(command = nil) { ... }
Send the given command to the redis server or cluster.
Class Method Details
+ (Boolean) accept?(obj)
23 24 25 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-redis/redis_connection.rb', line 23 def @@j_api_type.accept?(obj) obj.class == RedisConnection end |
+ (Object) j_api_type
32 33 34 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-redis/redis_connection.rb', line 32 def self.j_api_type @@j_api_type end |
+ (Object) j_class
35 36 37 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-redis/redis_connection.rb', line 35 def self.j_class Java::IoVertxRedisClient::RedisConnection.java_class end |
+ (Object) unwrap(obj)
29 30 31 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-redis/redis_connection.rb', line 29 def @@j_api_type.unwrap(obj) obj.j_del end |
+ (Object) wrap(obj)
26 27 28 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-redis/redis_connection.rb', line 26 def @@j_api_type.wrap(obj) RedisConnection.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.
139 140 141 142 143 144 145 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-redis/redis_connection.rb', line 139 def batch(commands=nil) if commands.class == Array && block_given? @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) })) return self end raise ArgumentError, "Invalid arguments when calling batch(#{commands})" end |
- (void) close
This method returns an undefined value.
Closes the connection or returns to the pool.
148 149 150 151 152 153 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-redis/redis_connection.rb', line 148 def close if !block_given? return @j_del.java_method(:close, []).call() end raise ArgumentError, "Invalid arguments when calling close()" end |
- (self) end_handler { ... }
116 117 118 119 120 121 122 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-redis/redis_connection.rb', line 116 def end_handler if block_given? @j_del.java_method(:endHandler, [Java::IoVertxCore::Handler.java_class]).call(Proc.new { yield }) return self end raise ArgumentError, "Invalid arguments when calling end_handler()" end |
- (self) exception_handler { ... }
68 69 70 71 72 73 74 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-redis/redis_connection.rb', line 68 def exception_handler if block_given? @j_del.java_method(:exceptionHandler, [Java::IoVertxCore::Handler.java_class]).call((Proc.new { |event| yield(::Vertx::Util::Utils.from_throwable(event)) })) return self end raise ArgumentError, "Invalid arguments when calling exception_handler()" end |
- (self) fetch(amount = nil)
106 107 108 109 110 111 112 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-redis/redis_connection.rb', line 106 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 { ... }
78 79 80 81 82 83 84 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-redis/redis_connection.rb', line 78 def handler if block_given? @j_del.java_method(:handler, [Java::IoVertxCore::Handler.java_class]).call((Proc.new { |event| yield(::Vertx::Util::Utils.safe_create(event,::VertxRedis::Response)) })) return self end raise ArgumentError, "Invalid arguments when calling handler()" end |
- (self) pause
87 88 89 90 91 92 93 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-redis/redis_connection.rb', line 87 def pause if !block_given? @j_del.java_method(:pause, []).call() return self end raise ArgumentError, "Invalid arguments when calling pause()" end |
- (true, false) pending_queue_full?
Flag to notify if the pending message queue (commands in transit) is full.
When the pending message queue is full and a new send command is issued it will result in a exception to be thrown.
Checking this flag before sending can allow the application to wait before sending the next message.
159 160 161 162 163 164 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-redis/redis_connection.rb', line 159 def pending_queue_full? if !block_given? return @j_del.java_method(:pendingQueueFull, []).call() end raise ArgumentError, "Invalid arguments when calling pending_queue_full?()" 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
.
42 43 44 45 46 47 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-redis/redis_connection.rb', line 42 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.
57 58 59 60 61 62 63 64 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-redis/redis_connection.rb', line 57 def pipe_to(dst=nil) if dst.class.method_defined?(:j_del) && !block_given? return @j_del.java_method(:pipeTo, [Java::IoVertxCoreStreams::WriteStream.java_class]).call(dst.j_del) elsif dst.class.method_defined?(:j_del) && block_given? 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) })) end raise ArgumentError, "Invalid arguments when calling pipe_to(#{dst})" end |
- (self) resume
96 97 98 99 100 101 102 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-redis/redis_connection.rb', line 96 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.
127 128 129 130 131 132 133 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-redis/redis_connection.rb', line 127 def send(command=nil) if command.class.method_defined?(:j_del) && block_given? @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) })) return self end raise ArgumentError, "Invalid arguments when calling send(#{command})" end |