@@ -41,7 +41,7 @@ import org.springframework.util.ReflectionUtils;
|
||||
|
||||
/**
|
||||
* {@link org.springframework.cache.Cache} implementation using for Redis as the underlying store for cache data.
|
||||
*
|
||||
* <p>
|
||||
* Use {@link RedisCacheManager} to create {@link RedisCache} instances.
|
||||
*
|
||||
* @author Christoph Strobl
|
||||
@@ -52,6 +52,7 @@ import org.springframework.util.ReflectionUtils;
|
||||
* @see org.springframework.cache.support.AbstractValueAdaptingCache
|
||||
* @since 2.0
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
public class RedisCache extends AbstractValueAdaptingCache {
|
||||
|
||||
private static final byte[] BINARY_NULL_VALUE = RedisSerializer.java().serialize(NullValue.INSTANCE);
|
||||
@@ -136,7 +137,8 @@ public class RedisCache extends AbstractValueAdaptingCache {
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private synchronized @Nullable <T> T getSynchronized(Object key, Callable<T> valueLoader) {
|
||||
@Nullable
|
||||
private synchronized <T> T getSynchronized(Object key, Callable<T> valueLoader) {
|
||||
|
||||
ValueWrapper result = get(key);
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ import org.springframework.util.Assert;
|
||||
/**
|
||||
* Immutable {@link RedisCacheConfiguration} used to customize {@link RedisCache} behaviour, such as caching
|
||||
* {@literal null} values, computing cache key prefixes and handling binary serialization.
|
||||
*
|
||||
* <p>
|
||||
* Start with {@link RedisCacheConfiguration#defaultCacheConfig()} and customize {@link RedisCache} behaviour
|
||||
* from that point on.
|
||||
*
|
||||
@@ -344,9 +344,9 @@ public class RedisCacheConfiguration {
|
||||
|
||||
/**
|
||||
* Registers default cache {@link Converter key converters}.
|
||||
*
|
||||
* <p>
|
||||
* The following converters get registered:
|
||||
*
|
||||
* <p>
|
||||
* <ul>
|
||||
* <li>{@link String} to {@link byte byte[]} using UTF-8 encoding.</li>
|
||||
* <li>{@link SimpleKey} to {@link String}</li>
|
||||
|
||||
@@ -18,7 +18,7 @@ package org.springframework.data.redis.connection;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* Interface for the commands supported by Redis.
|
||||
* Interface defining the commands supported by Redis.
|
||||
*
|
||||
* @author Costin Leau
|
||||
* @author Christoph Strobl
|
||||
@@ -29,14 +29,16 @@ public interface RedisCommands extends RedisKeyCommands, RedisStringCommands, Re
|
||||
RedisServerCommands, RedisStreamCommands, RedisScriptingCommands, RedisGeoCommands, RedisHyperLogLogCommands {
|
||||
|
||||
/**
|
||||
* 'Native' or 'raw' execution of the given command along-side the given arguments. The command is executed as is,
|
||||
* with as little 'interpretation' as possible - it is up to the caller to take care of any processing of arguments or
|
||||
* the result.
|
||||
* {@literal Native} or {@literal raw} execution of the given Redis command along with the given arguments.
|
||||
* <p>
|
||||
* The command is executed as is, with as little interpretation as possible - it is up to the caller to take care
|
||||
* of any processing of arguments or the result.
|
||||
*
|
||||
* @param command Command to execute. must not be {@literal null}.
|
||||
* @param args Possible command arguments (may be empty).
|
||||
* @return execution result. Can be {@literal null}.
|
||||
* @param command Redis {@link String command} to execute; must not be {@literal null}.
|
||||
* @param args optional array of command arguments; may be empty;
|
||||
* @return the execution result; may be {@literal null}.
|
||||
*/
|
||||
@Nullable
|
||||
Object execute(String command, byte[]... args);
|
||||
|
||||
}
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.data.redis.connection;
|
||||
|
||||
import org.springframework.dao.support.PersistenceExceptionTranslator;
|
||||
@@ -23,45 +22,49 @@ import org.springframework.dao.support.PersistenceExceptionTranslator;
|
||||
*
|
||||
* @author Costin Leau
|
||||
* @author Christoph Strobl
|
||||
* @author John Blum
|
||||
*/
|
||||
public interface RedisConnectionFactory extends PersistenceExceptionTranslator {
|
||||
|
||||
/**
|
||||
* Provides a suitable connection for interacting with Redis.
|
||||
* Returns a suitable {@link RedisConnection connection} for interacting with Redis.
|
||||
*
|
||||
* @return connection for interacting with Redis.
|
||||
* @throws IllegalStateException if the connection factory requires initialization and the factory was not yet
|
||||
* initialized.
|
||||
* @return {@link RedisConnection connection} for interacting with Redis.
|
||||
* @throws IllegalStateException if the connection factory requires initialization and the factory has not yet
|
||||
* been initialized.
|
||||
*/
|
||||
RedisConnection getConnection();
|
||||
|
||||
/**
|
||||
* Provides a suitable connection for interacting with Redis Cluster.
|
||||
* Returns a suitable {@link RedisClusterConnection connection} for interacting with Redis Cluster.
|
||||
*
|
||||
* @return
|
||||
* @throws IllegalStateException if the connection factory requires initialization and the factory was not yet
|
||||
* initialized.
|
||||
* @return a {@link RedisClusterConnection connection} for interacting with Redis Cluster.
|
||||
* @throws IllegalStateException if the connection factory requires initialization and the factory has not yet
|
||||
* been initialized.
|
||||
* @since 1.7
|
||||
*/
|
||||
RedisClusterConnection getClusterConnection();
|
||||
|
||||
/**
|
||||
* Specifies if pipelined results should be converted to the expected data type. If false, results of
|
||||
* {@link RedisConnection#closePipeline()} and {RedisConnection#exec()} will be of the type returned by the underlying
|
||||
* driver This method is mostly for backwards compatibility with 1.0. It is generally always a good idea to allow
|
||||
* results to be converted and deserialized. In fact, this is now the default behavior.
|
||||
* Specifies if pipelined results should be converted to the expected data type.
|
||||
* <p>
|
||||
* If {@literal false}, results of {@link RedisConnection#closePipeline()} and {@link RedisConnection#exec()}
|
||||
* will be of the type returned by the underlying driver. This method is mostly for backwards compatibility
|
||||
* with {@literal 1.0}. It is generally always a good idea to allow results to be converted and deserialized.
|
||||
* In fact, this is now the default behavior.
|
||||
*
|
||||
* @return Whether or not to convert pipeline and tx results
|
||||
* @return a boolen indicating whether to convert pipeline and transaction results.
|
||||
*/
|
||||
boolean getConvertPipelineAndTxResults();
|
||||
|
||||
/**
|
||||
* Provides a suitable connection for interacting with Redis Sentinel.
|
||||
* Returns a suitable {@link RedisSentinelConnection connection} for interacting with Redis Sentinel.
|
||||
*
|
||||
* @return connection for interacting with Redis Sentinel.
|
||||
* @throws IllegalStateException if the connection factory requires initialization and the factory was not yet
|
||||
* initialized.
|
||||
* @return a {@link RedisSentinelConnection connection} for interacting with Redis Sentinel.
|
||||
* @throws IllegalStateException if the connection factory requires initialization and the factory has not yet
|
||||
* been initialized.
|
||||
* @since 1.4
|
||||
*/
|
||||
RedisSentinelConnection getSentinelConnection();
|
||||
|
||||
}
|
||||
|
||||
@@ -25,17 +25,22 @@ import org.springframework.lang.Nullable;
|
||||
* {@code get/set/trim etc...}.
|
||||
*
|
||||
* @author Costin Leau
|
||||
* @author John Blum
|
||||
*/
|
||||
public interface RedisCallback<T> {
|
||||
|
||||
/**
|
||||
* Gets called by {@link RedisTemplate} with an active Redis connection. Does not need to care about activating or
|
||||
* closing the connection or handling exceptions.
|
||||
* Method called by {@link RedisTemplate} with an active {@link RedisConnection}.
|
||||
* <p>
|
||||
* Callback code need not care about activating/opening or closing the {@link RedisConnection},
|
||||
* nor handling {@link Exception exceptions}.
|
||||
*
|
||||
* @param connection active Redis connection
|
||||
* @return a result object or {@code null} if none
|
||||
* @throws DataAccessException
|
||||
* @param connection active {@link RedisConnection Redis connection}.
|
||||
* @return the {@link Object result} of the operation performed in the callback or {@code null}.
|
||||
* @throws DataAccessException if the operation performed by the callback fails to execute in the context of Redis
|
||||
* using the given {@link RedisConnection}.
|
||||
*/
|
||||
@Nullable
|
||||
T doInRedis(RedisConnection connection) throws DataAccessException;
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user