Saievskiy Dmitriy
Saievskiy Dmitriy

Reputation: 37

Can I use spring data repository interface for cassandra async inserts?

@Repository
public interface RoundRepository extends CassandraRepository<Round, String> {
    List<Round> findByInstanceId(String instanceId, Pageable pageable);

    Round findByInstanceIdAndRound(String instanceId, long round);

    long countByInstanceId(String instanceId);
}

I have repositories like this. And I want to use them to do async inserts and sync everything else. Can I do it in this style without native queries via AsyncCassandraTemplate? Didn't found any tips

Upvotes: 1

Views: 411

Answers (1)

Aaron
Aaron

Reputation: 57798

Yes, Spring has a doc on getting Async Query Results via custom repository methods. Basically, you can use the @Async annotation and then wrap the return type with one of the *Future types.

So in your case, countByInstanceId might look something like this:

@Async
ListenableFuture<long> countByInstanceId(String instanceId);

Upvotes: 1

Related Questions