Search code examples
cassandracql3spring-data-cassandra

How to mark query as idempotent in spring-data-cassandra?


I'm migrating from code that uses Cassandra java driver directly to a spring-data-cassandra. Old code used com.datastax.driver.core.PreparedStatement#setIdempotent to mark some queries as idempotent (that provides performance/latency bonus in some cases)

Is there any way to set this property when working through spring-data-cassandra or through spring-cql? I would expect it to be an option for @Query annotation, or a separate annotation on query method, or at least a part of QueryOptions

The only related thing I found is https://jira.spring.io/browse/DATACASS-403 , looks like org.springframework.cassandra.core.CachedPreparedStatementCreator that is used at CassandraTemplate, does not support idempotent flag (and even resets this flag for manually-built queries). Moreover, I did not find any mention at 2.0 spring-data-cassandra branch on github


Solution

  • No, it's not planned for 2.0 yet because the caching is broken and the whole point of idempotent query is to make it cacheable.

    There won't be a built in support for this flag until caching issues are fixed. When I looked at this issue, https://jira.spring.io/browse/DATACASS-291 was the main culprit (IMHO) that was blocking this flag from being usable