thurstonsand / scala-cass

a wrapper for the Java Cassandra driver that allows extraction from a Row with Scala types, or directly into a case class. Also has utility functions for the Session to read/write to Cassandra directly to/from a case class.
MIT License
21 stars 10 forks source link

When creating an insert statement, allow specifying ttl and consistency level parameters. #43

Closed SajithaN closed 6 years ago

thurstonsand commented 6 years ago

insert statements already allow TTL. write like

sSession.insert("mytable", MyCaseClass(myValue)).usingTTL(1234).execute()

could you clarify what you mean by consistency level? I don't see that in the docs

SajithaN commented 6 years ago

I am thinking about write consistency levels: https://docs.datastax.com/en/cassandra/3.0/cassandra/dml/dmlConfigConsistency.html#dmlConfigConsistency__dml-config-write-consistency

It can be set on PreparedStatement object.

`PreparedStatement setConsistencyLevel(ConsistencyLevel consistency) Sets a default consistency level for all bound statements created from this prepared statement. If no consistency level is set through this method, the bound statement created from this object will use the default consistency level (ONE).

Changing the default consistency level is not retroactive, it only applies to BoundStatement created after the change.

Parameters: consistency - the default consistency level to set. Returns: this PreparedStatement object.`

https://docs.datastax.com/en/drivers/java/2.0/com/datastax/driver/core/PreparedStatement.html#setConsistencyLevel-com.datastax.driver.core.ConsistencyLevel-

SajithaN commented 6 years ago

It can also be on Batch level:

val batch = new BatchStatement(batchType); batch.setConsistencyLevel(consistencyLevel)

thurstonsand commented 6 years ago

ah I understand. I'll look into this