Class List Method List File List

# Class: VertxWeb::LocalSessionStore

Inherits:
  SessionStore
  - Object
  - SessionStore
  - VertxWeb::LocalSessionStore
  show all
Defined in:
  /Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/local_session_store.rb

## Overview

A session store which is only available on a single node.

Can be used when sticky sessions are being used.

## Constant Summary

@@j_api_type =

      Object.new

## Class Method Summary (collapse)

- + (Boolean) accept?(obj)
- + (::VertxWeb::LocalSessionStore) create(vertx = nil, sessionMapName = nil, reaperInterval = nil)
  Create a session store.
- + (Object) DEFAULT_REAPER_INTERVAL
  Default of how often, in ms, to check for expired sessions.
- + (Object) DEFAULT_SESSION_MAP_NAME
  Default name for map used to store sessions.
- + (Object) DEFAULT_SESSIONID_LENGTH
  Default length for a session id.
- + (Object) j_api_type
- + (Object) j_class
- + (Object) unwrap(obj)
- + (Object) wrap(obj)

## Instance Method Summary (collapse)

- - (void) clear { ... }
  Remove all sessions from the store.
- - (void) close
  Close the store.
- - (::VertxWeb::Session) create_session(timeout = nil, length = nil)
  Create a new session.
- - (void) delete(id = nil) { ... }
  Delete the session with the specified ID.
- - (void) get(cookieValue = nil) { ... }
  Get the session with the specified ID.
- - (self) init(vertx = nil, options = nil)
  Initialize this store.
- - (void) put(session = nil) { ... }
  Add a session with the specified ID.
- - (Fixnum) retry_timeout
  The retry timeout value in milli seconds used by the session handler when it retrieves a value from the store.
- - (void) size { ... }
  Get the number of sessions in the store.

## Class Method Details

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

Returns:

- (`Boolean`)

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

    def @@j_api_type.accept?(obj)
      obj.class == LocalSessionStore
    end

### + (`::VertxWeb::LocalSessionStore`) create(vertx = nil, sessionMapName = nil, reaperInterval = nil)

Create a session store

Parameters:

- vertx (`::Vertx::Vertx`) (defaults to: `nil`) —
  the Vert.x instance
- sessionMapName (`String`) (defaults to: `nil`) —
  name for map used to store sessions
- reaperInterval (`Fixnum`) (defaults to: `nil`) —
  how often, in ms, to check for expired sessions

Returns:

- (`::VertxWeb::LocalSessionStore`) —
  the session store

Raises:

- (`ArgumentError`)

    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/local_session_store.rb', line 134

    def self.create(vertx=nil,sessionMapName=nil,reaperInterval=nil)
      if vertx.class.method_defined?(:j_del) && !block_given? && sessionMapName == nil && reaperInterval == nil
        return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtWebSstore::LocalSessionStore.java_method(:create, [Java::IoVertxCore::Vertx.java_class]).call(vertx.j_del),::VertxWeb::LocalSessionStore)
      elsif vertx.class.method_defined?(:j_del) && sessionMapName.class == String && !block_given? && reaperInterval == nil
        return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtWebSstore::LocalSessionStore.java_method(:create, [Java::IoVertxCore::Vertx.java_class,Java::java.lang.String.java_class]).call(vertx.j_del,sessionMapName),::VertxWeb::LocalSessionStore)
      elsif vertx.class.method_defined?(:j_del) && sessionMapName.class == String && reaperInterval.class == Fixnum && !block_given?
        return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtWebSstore::LocalSessionStore.java_method(:create, [Java::IoVertxCore::Vertx.java_class,Java::java.lang.String.java_class,Java::long.java_class]).call(vertx.j_del,sessionMapName,reaperInterval),::VertxWeb::LocalSessionStore)
      end
      raise ArgumentError, "Invalid arguments when calling create(#{vertx},#{sessionMapName},#{reaperInterval})"
    end

### + (`Object`) DEFAULT_REAPER_INTERVAL

Default of how often, in ms, to check for expired sessions

    150
    151
    152
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/local_session_store.rb', line 150

    def self.DEFAULT_REAPER_INTERVAL
      Java::IoVertxExtWebSstore::LocalSessionStore.DEFAULT_REAPER_INTERVAL
    end

### + (`Object`) DEFAULT_SESSION_MAP_NAME

Default name for map used to store sessions

    154
    155
    156
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/local_session_store.rb', line 154

    def self.DEFAULT_SESSION_MAP_NAME
      Java::IoVertxExtWebSstore::LocalSessionStore.DEFAULT_SESSION_MAP_NAME
    end

### + (`Object`) DEFAULT_SESSIONID_LENGTH

Default length for a session id. More info: https://www.owasp.org/index.php/Session_Management_Cheat_Sheet

    146
    147
    148
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/local_session_store.rb', line 146

    def self.DEFAULT_SESSIONID_LENGTH
      Java::IoVertxExtWebSstore::LocalSessionStore.DEFAULT_SESSIONID_LENGTH
    end

### + (`Object`) j_api_type

    32
    33
    34
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/local_session_store.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-web/local_session_store.rb', line 35

    def self.j_class
      Java::IoVertxExtWebSstore::LocalSessionStore.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-web/local_session_store.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-web/local_session_store.rb', line 26

    def @@j_api_type.wrap(obj)
      LocalSessionStore.new(obj)
    end

## Instance Method Details

### - (`void`) clear { ... }

This method returns an undefined value.

Remove all sessions from the store.

Yields:

- will be called with a success or a failure

Raises:

- (`ArgumentError`)

    104
    105
    106
    107
    108
    109
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/local_session_store.rb', line 104

    def clear
      if block_given?
        return @j_del.java_method(:clear, [Java::IoVertxCore::Handler.java_class]).call((Proc.new { |ar| yield(ar.failed ? ar.cause : nil) }))
      end
      raise ArgumentError, "Invalid arguments when calling clear()"
    end

### - (`void`) close

This method returns an undefined value.

Close the store

Raises:

- (`ArgumentError`)

    123
    124
    125
    126
    127
    128
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/local_session_store.rb', line 123

    def close
      if !block_given?
        return @j_del.java_method(:close, []).call()
      end
      raise ArgumentError, "Invalid arguments when calling close()"
    end

### - (`::VertxWeb::Session`) create_session(timeout = nil, length = nil)

Create a new session.

Parameters:

- timeout (`Fixnum`) (defaults to: `nil`) —
  - the session timeout, in ms
- length (`Fixnum`) (defaults to: `nil`) —
  - the required length for the session id

Returns:

- (`::VertxWeb::Session`) —
  the session

Raises:

- (`ArgumentError`)

    63
    64
    65
    66
    67
    68
    69
    70
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/local_session_store.rb', line 63

    def create_session(timeout=nil,length=nil)
      if timeout.class == Fixnum && !block_given? && length == nil
        return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:createSession, [Java::long.java_class]).call(timeout),::VertxWeb::Session)
      elsif timeout.class == Fixnum && length.class == Fixnum && !block_given?
        return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:createSession, [Java::long.java_class,Java::int.java_class]).call(timeout,length),::VertxWeb::Session)
      end
      raise ArgumentError, "Invalid arguments when calling create_session(#{timeout},#{length})"
    end

### - (`void`) delete(id = nil) { ... }

This method returns an undefined value.

Delete the session with the specified ID.

Parameters:

- id (`String`) (defaults to: `nil`) —
  the session id

Yields:

- will be called with a success or a failure

Raises:

- (`ArgumentError`)

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

    def delete(id=nil)
      if id.class == String && block_given?
        return @j_del.java_method(:delete, [Java::java.lang.String.java_class,Java::IoVertxCore::Handler.java_class]).call(id,(Proc.new { |ar| yield(ar.failed ? ar.cause : nil) }))
      end
      raise ArgumentError, "Invalid arguments when calling delete(#{id})"
    end

### - (`void`) get(cookieValue = nil) { ... }

This method returns an undefined value.

Get the session with the specified ID.

Parameters:

- cookieValue (`String`) (defaults to: `nil`) —
  the unique ID of the session

Yields:

- will be called with a result holding the session, or a failure

Raises:

- (`ArgumentError`)

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

    def get(cookieValue=nil)
      if cookieValue.class == String && block_given?
        return @j_del.java_method(:get, [Java::java.lang.String.java_class,Java::IoVertxCore::Handler.java_class]).call(cookieValue,(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ::Vertx::Util::Utils.safe_create(ar.result,::VertxWeb::Session) : nil) }))
      end
      raise ArgumentError, "Invalid arguments when calling get(#{cookieValue})"
    end

### - (`self`) init(vertx = nil, options = nil)

Initialize this store.

Parameters:

- vertx (`::Vertx::Vertx`) (defaults to: `nil`) —
  the vertx instance
- options (`Hash{String => Object}`) (defaults to: `nil`) —
  optional Json with extra configuration options

Returns:

- (`self`)

Raises:

- (`ArgumentError`)

    42
    43
    44
    45
    46
    47
    48
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/local_session_store.rb', line 42

    def init(vertx=nil,options=nil)
      if vertx.class.method_defined?(:j_del) && options.class == Hash && !block_given?
        @j_del.java_method(:init, [Java::IoVertxCore::Vertx.java_class,Java::IoVertxCoreJson::JsonObject.java_class]).call(vertx.j_del,::Vertx::Util::Utils.to_json_object(options))
        return self
      end
      raise ArgumentError, "Invalid arguments when calling init(#{vertx},#{options})"
    end

### - (`void`) put(session = nil) { ... }

This method returns an undefined value.

Add a session with the specified ID.

Parameters:

- session (`::VertxWeb::Session`) (defaults to: `nil`) —
  the session

Yields:

- will be called with a success or a failure

Raises:

- (`ArgumentError`)

    95
    96
    97
    98
    99
    100
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/local_session_store.rb', line 95

    def put(session=nil)
      if session.class.method_defined?(:j_del) && block_given?
        return @j_del.java_method(:put, [Java::IoVertxExtWeb::Session.java_class,Java::IoVertxCore::Handler.java_class]).call(session.j_del,(Proc.new { |ar| yield(ar.failed ? ar.cause : nil) }))
      end
      raise ArgumentError, "Invalid arguments when calling put(#{session})"
    end

### - (`Fixnum`) retry_timeout

The retry timeout value in milli seconds used by the session handler when it retrieves a value from the store.

A non positive value means there is no retry at all.

Returns:

- (`Fixnum`) —
  the timeout value, in ms

Raises:

- (`ArgumentError`)

    53
    54
    55
    56
    57
    58
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/local_session_store.rb', line 53

    def retry_timeout
      if !block_given?
        return @j_del.java_method(:retryTimeout, []).call()
      end
      raise ArgumentError, "Invalid arguments when calling retry_timeout()"
    end

### - (`void`) size { ... }

This method returns an undefined value.

Get the number of sessions in the store.

Beware of the result which is just an estimate, in particular with distributed session stores.

Yields:

- will be called with the number, or a failure

Raises:

- (`ArgumentError`)

    115
    116
    117
    118
    119
    120
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/local_session_store.rb', line 115

    def size
      if block_given?
        return @j_del.java_method(:size, [Java::IoVertxCore::Handler.java_class]).call((Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ar.result : nil) }))
      end
      raise ArgumentError, "Invalid arguments when calling size()"
    end