Class: VertxRedis::Redis
- Inherits:
-
Object
- Object
- VertxRedis::Redis
- 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(*args)
Create a new redis client using the given client options.
- + (Object) j_api_type
- + (Object) j_class
- + (Object) unwrap(obj)
- + (Object) wrap(obj)
Instance Method Summary (collapse)
-
- (self) batch(commands, onSend) { ... }
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 client and terminates any connection.
-
- (self) connect(handler) { ... }
Connects to the redis server.
-
- (self) send(command, onSend) { ... }
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.rb', line 23 def @@j_api_type.accept?(obj) obj.class == Redis end |
+ (::VertxRedis::Redis) createClient(vertx) + (::VertxRedis::Redis) createClient(vertx, connectionString) + (::VertxRedis::Redis) createClient(vertx, options)
Create a new redis client using the given client options.
48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-redis/redis.rb', line 48 def self.create_client(*args) if args[0].class.method_defined?(:j_del) && !block_given? && args[1] == nil return ::Vertx::Util::Utils.safe_create(Java::IoVertxRedisClient::Redis.java_method(:createClient, [Java::IoVertxCore::Vertx.java_class]).call(args[0].j_del),::VertxRedis::Redis) elsif args[0].class.method_defined?(:j_del) && args[1].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(args[0].j_del,args[1]),::VertxRedis::Redis) elsif args[0].class.method_defined?(:j_del) && args[1].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(args[0].j_del,Java::IoVertxRedisClient::RedisOptions.new(::Vertx::Util::Utils.to_json_object(args[1]))),::VertxRedis::Redis) end if defined?(super) super else raise ArgumentError, "Invalid arguments when calling create_client(#{args[0]},#{args[1]})" end 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.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.rb', line 35 def self.j_class Java::IoVertxRedisClient::Redis.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.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.rb', line 26 def @@j_api_type.wrap(obj) Redis.new(obj) end |
Instance Method Details
- (self) batch(commands, onSend) { ... }
Sends a list of commands in a single IO operation, this prevents any inter twinning to happen from other
client users.
68 69 70 71 72 73 74 75 76 77 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.rb', line 68 def batch(*args) if args[0].class == Array && true if (block_given?) @j_del.java_method(:batch, [Java::JavaUtil::List.java_class,Java::IoVertxCore::Handler.java_class]).call(args[0].map { |element| element.j_del },block_given? ? 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) } : promise) return self else promise = ::Vertx::Util::Utils.promise @j_del.java_method(:batch, [Java::JavaUtil::List.java_class,Java::IoVertxCore::Handler.java_class]).call(args[0].map { |element| element.j_del },block_given? ? 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) } : promise) return ::Vertx::Util::Utils.safe_create(promise.future(),::Vertx::Future, nil) end end if defined?(super) super else raise ArgumentError, "Invalid arguments when calling batch(#{args[0]})" end end |
- (void) close
This method returns an undefined value.
Closes the client and terminates any connection.
110 111 112 113 114 115 116 117 118 119 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-redis/redis.rb', line 110 def close if !block_given? return @j_del.java_method(:close, []).call() end if defined?(super) super else raise ArgumentError, "Invalid arguments when calling close()" end end |
- (self) connect(handler) { ... }
Connects to the redis server.
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-redis/redis.rb', line 124 def connect if true if (block_given?) @j_del.java_method(:connect, [Java::IoVertxCore::Handler.java_class]).call(block_given? ? Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ::Vertx::Util::Utils.safe_create(ar.result,::VertxRedis::RedisConnection) : nil) } : promise) return self else promise = ::Vertx::Util::Utils.promise @j_del.java_method(:connect, [Java::IoVertxCore::Handler.java_class]).call(block_given? ? Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ::Vertx::Util::Utils.safe_create(ar.result,::VertxRedis::RedisConnection) : nil) } : promise) return ::Vertx::Util::Utils.safe_create(promise.future(),::Vertx::Future,::VertxRedis::RedisConnection.j_api_type) end end if defined?(super) super else raise ArgumentError, "Invalid arguments when calling connect()" end end |
- (self) send(command, onSend) { ... }
Send the given command to the redis server or cluster.
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-redis/redis.rb', line 90 def send(*args) if args[0].class.method_defined?(:j_del) && true if (block_given?) @j_del.java_method(:send, [Java::IoVertxRedisClient::Request.java_class,Java::IoVertxCore::Handler.java_class]).call(args[0].j_del,block_given? ? Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ::Vertx::Util::Utils.safe_create(ar.result,::VertxRedis::Response) : nil) } : promise) return self else promise = ::Vertx::Util::Utils.promise @j_del.java_method(:send, [Java::IoVertxRedisClient::Request.java_class,Java::IoVertxCore::Handler.java_class]).call(args[0].j_del,block_given? ? Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ::Vertx::Util::Utils.safe_create(ar.result,::VertxRedis::Response) : nil) } : promise) return ::Vertx::Util::Utils.safe_create(promise.future(),::Vertx::Future,::VertxRedis::Response.j_api_type) end end if defined?(super) super else raise ArgumentError, "Invalid arguments when calling send(#{args[0]})" end end |