Class: VertxRedis::Redis

Inherits:
Object
  • Object
show all
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)

Instance Method Summary (collapse)

Class Method Details

+ (Boolean) accept?(obj)

Returns:

  • (Boolean)

21
22
23
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-redis/redis.rb', line 21

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.

Overloads:

Returns:

Raises:

  • (ArgumentError)

46
47
48
49
50
51
52
53
54
55
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-redis/redis.rb', line 46

def self.create_client(param_1=nil,param_2=nil)
  if param_1.class.method_defined?(:j_del) && !block_given? && param_2 == nil
    return ::Vertx::Util::Utils.safe_create(Java::IoVertxRedisClient::Redis.java_method(:createClient, [Java::IoVertxCore::Vertx.java_class]).call(param_1.j_del),::VertxRedis::Redis)
  elsif 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


30
31
32
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-redis/redis.rb', line 30

def self.j_api_type
  @@j_api_type
end

+ (Object) j_class


33
34
35
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-redis/redis.rb', line 33

def self.j_class
  Java::IoVertxRedisClient::Redis.java_class
end

+ (Object) unwrap(obj)


27
28
29
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-redis/redis.rb', line 27

def @@j_api_type.unwrap(obj)
  obj.j_del
end

+ (Object) wrap(obj)


24
25
26
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-redis/redis.rb', line 24

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.

Parameters:

Yields:

  • the asynchronous result handler.

Returns:

  • (self)

Raises:

  • (ArgumentError)

90
91
92
93
94
95
96
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-redis/redis.rb', line 90

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 client and terminates any connection.

Raises:

  • (ArgumentError)

68
69
70
71
72
73
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-redis/redis.rb', line 68

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.

Yields:

  • the async result handler

Returns:

  • (self)

Raises:

  • (ArgumentError)

59
60
61
62
63
64
65
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-redis/redis.rb', line 59

def connect
  if block_given?
    @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::RedisConnection) : nil) }))
    return self
  end
  raise ArgumentError, "Invalid arguments when calling connect()"
end

- (self) send(command = nil) { ... }

Send the given command to the redis server or cluster.

Parameters:

Yields:

  • the asynchronous result handler.

Returns:

  • (self)

Raises:

  • (ArgumentError)

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 78

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