I am using https://github.com/gocql/gocql. I want to set the read/write consistency of cassandra.
cluster := gocql.NewCluster(hosts...)
cluster.Consistency = gocql.ParseConsistency(consistency)
If the consistency setting is applied as above, is both read/write consistency applied? Or is there a way to apply read and write consistency separately?
You can set the global consistency with:
This will apply to both reads and writes. There is no way to configure a different CL for either just reads or just writes with the GoCQL driver.
As an alternative, you can set the consistency for the session or just the query with either
Consistency()orSetConsistency(). For example:The valid consistency constants are:
Note that the general recommendation is to use local quorum for almost all cases. Cheers!