Class List Method List File List

# Class: VertxRedis::Redis

Inherits:
  Object
  - Object
  - VertxRedis::Redis
  show all
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) { ... }
- - (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) { ... }
- - (::Vertx::SocketAddress) socket_address
  Returns the address associated with this client.

## Class Method Details

### + (`Boolean`) accept?(obj)

Returns:

- (`Boolean`)

    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.

Overloads:

- + (`::VertxRedis::Redis`) createClient(vertx, address)

  Parameters:

  - vertx (`::Vertx::Vertx`)
  - address (`::Vertx::SocketAddress`)
- + (`::VertxRedis::Redis`) createClient(vertx, options)

  Parameters:

  - vertx (`::Vertx::Vertx`)
  - options (`Hash`)

Returns:

- (`::VertxRedis::Redis`)

Raises:

- (`ArgumentError`)

    75
    76
    77
    78
    79
    80
    81
    82
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-redis/redis.rb', line 75

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

Parameters:

- commands (`Array<::VertxRedis::Request>`) (defaults to: `nil`)

Yields:

Returns:

- (`self`)

Raises:

- (`ArgumentError`)

    170
    171
    172
    173
    174
    175
    176
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-redis/redis.rb', line 170

    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.

Raises:

- (`ArgumentError`)

    186
    187
    188
    189
    190
    191
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-redis/redis.rb', line 186

    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`)

    86
    87
    88
    89
    90
    91
    92
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-redis/redis.rb', line 86

    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::Redis) : nil) }))
        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.

Yields:

Returns:

- (`self`)

Raises:

- (`ArgumentError`)

    150
    151
    152
    153
    154
    155
    156
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-redis/redis.rb', line 150

    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 { ... }

Set an exception handler on the read stream.

Yields:

- the exception handler

Returns:

- (`self`)

Raises:

- (`ArgumentError`)

    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.rb', line 96

    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)

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.

Parameters:

- amount (`Fixnum`) (defaults to: `nil`)

Returns:

- (`self`)

Raises:

- (`ArgumentError`)

    140
    141
    142
    143
    144
    145
    146
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-redis/redis.rb', line 140

    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.

Yields:

Returns:

- (`self`)

Raises:

- (`ArgumentError`)

    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.rb', line 106

    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

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`.

Returns:

- (`self`)

Raises:

- (`ArgumentError`)

    117
    118
    119
    120
    121
    122
    123
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-redis/redis.rb', line 117

    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`.

Returns:

- (`::Vertx::Pipe`) —
  a pipe

Raises:

- (`ArgumentError`)

    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 this `ReadStream` 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.

Parameters:

- dst (`::Vertx::WriteStream`) (defaults to: `nil`) —
  the destination write stream

Yields:

Raises:

- (`ArgumentError`)

    59
    60
    61
    62
    63
    64
    65
    66
    # 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) && !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

Resume reading, and sets the buffer in `flowing` mode.

If the `ReadStream` has been paused, reading will recommence on it.

Returns:

- (`self`)

Raises:

- (`ArgumentError`)

    128
    129
    130
    131
    132
    133
    134
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-redis/redis.rb', line 128

    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) { ... }

Parameters:

- command (`::VertxRedis::Request`) (defaults to: `nil`)

Yields:

Returns:

- (`self`)

Raises:

- (`ArgumentError`)

    160
    161
    162
    163
    164
    165
    166
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-redis/redis.rb', line 160

    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

### - (`::Vertx::SocketAddress`) socket_address

Returns the address associated with this client.

Returns:

- (`::Vertx::SocketAddress`) —
  the address.

Raises:

- (`ArgumentError`)

    179
    180
    181
    182
    183
    184
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-redis/redis.rb', line 179

    def socket_address
      if !block_given?
        return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:socketAddress, []).call(),::Vertx::SocketAddress)
      end
      raise ArgumentError, "Invalid arguments when calling socket_address()"
    end