Sessions are used for query execution. Each session tracks its current keyspace. A session should be reused as much as possible, however it is ok to create several independent session for interacting with different keyspaces in the same application.
Inherits
Object
Extends
Methods
Returns current keyspace
Returns:
Type
Details
String
current keyspace
Executes a given statement and returns a future result
Note
Last argument will be treated as options if it is a Hash.
Therefore, make sure to pass empty options when executing a statement
with the last parameter required to be a map datatype.
Note
Positional arguments are only supported on Apache Cassandra 2.0 and
above.
Parameters:
Keys for options :
Key
Type
Details
:consistency
Symbol
consistency level for the request.
Must be one of CONSISTENCIES
:page_size
Integer
size of results page. You can page
through results using Result#next_page or
Result#next_page_async
:trace
Boolean
default:
false
whether to enable request tracing
:timeout
Numeric
default:
nil
if specified, it is a number of
seconds after which to time out the request if it hasn’t completed
:serial_consistency
Symbol
default:
nil
this option is only
relevant for conditional updates and specifies a serial consistency to
be used, one of SERIAL_CONSISTENCIES
Returns:
See Also:
A blocking wrapper around #execute_async
Returns:
Type
Details
Result
query result
Raises:
See Also:
Prepares a given statement and returns a future prepared statement
Parameters:
Name
Type
Details
statement
(String or Statements::Simple )
a statement to
prepare
options
Hash
(defaults to: nil)
a customizable set of options
Keys for options :
Key
Type
Details
:trace
Boolean
default:
false
whether to enable request tracing
:timeout
Numeric
default:
nil
if specified, it is a number of
seconds after which to time out the request if it hasn’t completed
Returns:
Returns a logged Statements::Batch instance and optionally yields it to
a given block
Yield Parameters:
Returns:
Returns a unlogged Statements::Batch instance and optionally yields it
to a given block
Yield Parameters:
Returns:
Specifications:
Session#unlogged_batch creates an unlogged batch
batch = double ( 'batch' )
expect ( Statements :: Batch :: Unlogged ). to receive ( :new ). once . and_return ( batch )
expect ( session . unlogged_batch ). to eq ( batch )
Returns a counter Statements::Batch instance and optionally yields it
to a given block
Yield Parameters:
Returns:
Specifications:
Session#counter_batch creates a counter batch
batch = double ( 'batch' )
expect ( Statements :: Batch :: Counter ). to receive ( :new ). once . and_return ( batch )
expect ( session . counter_batch ). to eq ( batch )
Asynchronously closes current session
Returns:
Type
Details
Future <Session >
a future that resolves to
self once closed
Specifications:
Session#close_async uses Client#close
expect ( client ). to receive ( :close ). and_return ( Ione :: Future . resolved )
expect ( session . close_async ). to eq ( promise )
expect ( promise ). to have_received ( :fulfill ). once . with ( session )
Synchronously closes current session
Returns:
Type
Details
self
this session
See Also:
Specifications:
Session#close resolves a promise returned by #close_async
expect ( promise ). to receive ( :get ). once . and_return ( 'success' )
expect ( session . close ). to eq ( 'success' )
Returns a CLI-friendly session representation
Returns:
Type
Details
String
a CLI-friendly session representation