Module Cassandra
This module allows the creation of sessions and provides shorthand annotations for type encoding and batch statement creation.
Depending on how it will be initialized, it supports either the binary protocol v2 or v3:
require "cassandra" -- binary protocol v3 (Cassandra 2.0.x and 2.1.x) require "cassandra.v2" -- binary procotol v2 (Cassandra 2.0.x)
Shorthands to give a type to a value in a query:
session:execute("SELECT * FROM users WHERE id = ?", { cassandra.uuid("2644bada-852c-11e3-89fb-e0b9a54a6d93") })
Functions
new () | Instanciate a new Session. |
BatchStatement (batch_type) | Instanciate a BatchStatement. |
Functions
- new ()
-
Instanciate a new Session.
Create a socket with the cosocket API if in Nginx and available, fallback to luasocket otherwise.
The instanciated session will communicate using the binary protocol of the current cassandra
implementation being required.
Returns:
- session The created session.
- err Any Error encountered during the socket creation.
- BatchStatement (batch_type)
-
Instanciate a BatchStatement.
The instanciated batch will then provide an ":add()" method to add queries,
and can be executed by a session's ":execute()" function.
See the related BatchStatement module and batch.lua example.
See http://docs.datastax.com/en/cql/3.1/cql/cqlreference/batchr.html
Parameters:
- batch_type The type of this batch. Can be one of: 'Logged, Unlogged, Counter'