Module: Cassie::ConnectionHandler::Sessions

Extended by:
ActiveSupport::Concern
Included in:
Cassie::ConnectionHandler
Defined in:
lib/cassie/connection_handler/sessions.rb,
lib/cassie/connection_handler/sessions/instrumentation.rb

Defined Under Namespace

Modules: Instrumentation

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#sessionsHash{String => Cassandra::Session} (readonly)

Sessions cache containint sessions that have been opened to the Cluster#cluster

Returns:

  • (Hash{String => Cassandra::Session})

    The underlying driver sessions, keyed by keyspaced name



14
15
16
# File 'lib/cassie/connection_handler/sessions.rb', line 14

def sessions
  @sessions ||= {}
end

Instance Method Details

#session(keyspace = self.keyspace) ⇒ Cassandra::Session

Fetches a session from the sessions cache. If no session has been opened to the requested keyspace a new session is created to the Cluster#cluster and cached.

Parameters:

  • keyspace (String) (defaults to: self.keyspace)

    The keyspace used for session scope. If nil, session will not be scoped (scoped to global space).

Returns:

  • (Cassandra::Session)


23
24
25
# File 'lib/cassie/connection_handler/sessions.rb', line 23

def session(keyspace=self.keyspace)
  sessions[keyspace] || initialize_session(keyspace)
end