DATACASS-833 - Deprecate cached PreparedStatementCreator support classes.

Since Cassandra driver version 4, the driver itself tracks prepared statements so external prepared statement caching is no longer required.
This commit is contained in:
Mark Paluch
2020-12-07 11:41:47 +01:00
parent ed46d742eb
commit 8f3a262e54
6 changed files with 20 additions and 16 deletions

View File

@@ -18,15 +18,16 @@ package org.springframework.data.cassandra.core.cql;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import com.datastax.oss.driver.api.core.CqlIdentifier;
import com.datastax.oss.driver.api.core.CqlSession;
import com.datastax.oss.driver.api.core.DriverException;
import com.datastax.oss.driver.api.core.cql.PreparedStatement;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.util.Assert;
import com.datastax.oss.driver.api.core.CqlIdentifier;
import com.datastax.oss.driver.api.core.CqlSession;
import com.datastax.oss.driver.api.core.DriverException;
import com.datastax.oss.driver.api.core.cql.PreparedStatement;
/**
* This {@link PreparedStatementCreator} maintains a static cache of all prepared statements for the duration of the JVM
* runtime, more specific the lifecycle of the associated {@link ClassLoader}. When preparing statements with Cassandra,
@@ -38,8 +39,7 @@ import org.springframework.util.Assert;
* @author David Webb
* @author Mark Paluch
* @deprecated since 2.0. This class uses an unsafe, static held cache and is not able to prepare
* {@link com.datastax.driver.core.querybuilder.BuiltStatement}. Use
* {@link org.springframework.data.cassandra.core.cql.support.CachedPreparedStatementCreator}.
* {@link com.datastax.driver.core.querybuilder.BuiltStatement}.
*/
@Deprecated
public class CachedPreparedStatementCreator implements PreparedStatementCreator {

View File

@@ -24,14 +24,11 @@ import com.datastax.oss.driver.api.core.cql.SimpleStatement;
/**
* Trivial implementation of {@link PreparedStatementCreator}. This prepared statement creator simply prepares a
* statement from the CQL string.
* <p>
* This implementation is useful for testing. It should not be used in production systems with high volume reads and
* writes. Use {@link CachedPreparedStatementCreator} When preparing statements with Cassandra, each Statement should be
* prepared once and only once due to the overhead of preparing the statement.
* statement from the CQL string. Exposes the given CQL statement through {@link CqlProvider#getCql()},
*
* @author David Webb
* @author Mark Paluch
* @see CqlProvider
*/
public class SimplePreparedStatementCreator implements PreparedStatementCreator, CqlProvider {

View File

@@ -15,16 +15,16 @@
*/
package org.springframework.data.cassandra.core.cql.support;
import org.springframework.data.cassandra.core.cql.PreparedStatementCreator;
import org.springframework.data.cassandra.core.cql.QueryOptions;
import org.springframework.util.Assert;
import com.datastax.oss.driver.api.core.CqlSession;
import com.datastax.oss.driver.api.core.DriverException;
import com.datastax.oss.driver.api.core.cql.PreparedStatement;
import com.datastax.oss.driver.api.core.cql.SimpleStatement;
import com.datastax.oss.driver.api.core.cql.Statement;
import org.springframework.data.cassandra.core.cql.PreparedStatementCreator;
import org.springframework.data.cassandra.core.cql.QueryOptions;
import org.springframework.util.Assert;
/**
* {@link PreparedStatementCreator} implementation using caching of prepared statements.
* <p />
@@ -35,7 +35,9 @@ import org.springframework.util.Assert;
* @author Mark Paluch
* @since 2.0
* @see PreparedStatementCache
* @deprecated since 3.2, the Cassandra driver has a built-in prepared statement cache with makes external caching of prepared statements superfluous.
*/
@Deprecated
public class CachedPreparedStatementCreator implements PreparedStatementCreator {
private final PreparedStatementCache cache;

View File

@@ -36,7 +36,9 @@ import com.datastax.oss.driver.api.core.cql.SimpleStatement;
* @author Mark Paluch
* @author Aldo Bongio
* @since 2.0
* @deprecated since 3.2, the Cassandra driver has a built-in prepared statement cache with makes external caching of prepared statements superfluous.
*/
@Deprecated
public class MapPreparedStatementCache implements PreparedStatementCache {
private final Map<CacheKey, PreparedStatement> cache;

View File

@@ -31,7 +31,10 @@ import com.datastax.oss.driver.api.core.cql.SimpleStatement;
* @author Mark Paluch
* @since 2.0
* @see PreparedStatement
* @deprecated since 3.2, the Cassandra driver has a built-in prepared statement cache with makes external caching of
* prepared statements superfluous.
*/
@Deprecated
public interface PreparedStatementCache {
/**

View File

@@ -18,7 +18,7 @@ Spring Data for Apache Cassandra uses consistent naming conventions on objects i
[[cassandra.reactive.getting-started]]
== Getting Started
Spring Data for Apache Cassandra requires Apache Cassandra 2.1 or later and Datastax Java Driver 3.0 or later.
Spring Data for Apache Cassandra requires Apache Cassandra 2.1 or later and Datastax Java Driver 4.0 or later.
An easy way to quickly set up and bootstrap a working environment is to create a Spring-based project in https://spring.io/tools/sts[STS] or use https://start.spring.io/[Spring Initializer].
First, you need to set up a running Apache Cassandra server.