2
votes

I cannot seem to find a way to do this. There is nothing in the documentation (except for CQL examples or thrift examples). Has anyone done this before? I want to set the consistency for read and write. Or even if you could tell me how do I pass the consistency level for each individual read / write, that would be great.

There exists a way to set the consistency level when the keyspace is created. But what about the case where the keyspace already exists and you want to update the consistency level for it. If it can't be done, then why is it so, since it should normally be available.

4

4 Answers

2
votes

Zanson is correct - Consistency Level is determined on a query by query basis. So each Read and Write query you execute will have its own consistency level specified. I believe by default this is set to QUORUM. QUORUM is calculated based on the Keyspace's Replication Factor.

-> Replication Factor is defined at the keyspace level.

-> Read / Write Consistency Level is defined at the point of querying.

1
votes

This issue described here https://issues.apache.org/jira/browse/CASSANDRA-4734 they deleted available to set consistency level (CL) per-request (i.e. in CQL). And decided to set this in Column Famaly (CF) level.

unfortunaly :(

BUT if using php pro_cassandra - you can make so: https://github.com/Orange-OpenSource/YACassandraPDO/issues/13

0
votes

You want to update the replication factor. Consistency level refers to a single query. To update the replication factor from the cassandra-cli you want to use the 'update keyspace' command and change the strategy options.

UPDATE KEYSPACE demo WITH strategy_options = {replication_factor:1}
0
votes

You are mixing up consistency level (refers to a single query) and replication factor (set when the keyspace is created).

To change the replication factor for an existing keyspace, use the 'alter keyspace' command:

ALTER KEYSPACE demo WITH REPLICATION = {'class': 'SimpleStrategy', 'replication_factor': 1};

Sources: