类 DefaultRedisCacheWriter
java.lang.Object
com.sie.mbm.mom.framework.cache.DefaultRedisCacheWriter
- 所有已实现的接口:
org.springframework.data.redis.cache.CacheStatisticsProvider,org.springframework.data.redis.cache.RedisCacheWriter
public class DefaultRedisCacheWriter
extends Object
implements org.springframework.data.redis.cache.RedisCacheWriter
RedisCacheWriter implementation capable of reading/writing binary data from/to
Redis in standalone and cluster environments. Works upon a given
RedisConnectionFactory to obtain the actual RedisConnection. DefaultRedisCacheWriter can be used in
locking or
non-locking
mode. While non-locking aims for maximum performance it may result in
overlapping, non atomic, command execution for operations spanning multiple Redis
interactions like putIfAbsent. The locking counterpart prevents
command overlap by setting an explicit lock key and checking against presence of this
key which leads to additional requests and potential command wait times.-
嵌套类概要
从接口继承的嵌套类/接口 org.springframework.data.redis.cache.RedisCacheWriter
org.springframework.data.redis.cache.RedisCacheWriter.TtlFunction -
字段概要
字段修饰符和类型字段说明private final org.springframework.data.redis.connection.RedisConnectionFactoryprivate final Duration -
构造器概要
构造器限定符构造器说明DefaultRedisCacheWriter(org.springframework.data.redis.connection.RedisConnectionFactory connectionFactory) privateDefaultRedisCacheWriter(org.springframework.data.redis.connection.RedisConnectionFactory connectionFactory, Duration sleepTime) -
方法概要
修饰符和类型方法说明private voidcheckAndPotentiallyWaitUntilUnlocked(String name, org.springframework.data.redis.connection.RedisConnection connection) voidvoidprivate static byte[]createCacheLockKey(String name) (专用程序包) booleandoCheckLock(String name, org.springframework.data.redis.connection.RedisConnection connection) private Booleanprivate Longprivate <T> Texecute(String name, Function<org.springframework.data.redis.connection.RedisConnection, T> callback) private voidexecuteLockFree(Consumer<org.springframework.data.redis.connection.RedisConnection> callback) byte[]org.springframework.data.redis.cache.CacheStatisticsprivate boolean(专用程序包) voidExplicitly set a write lock on a cache.voidbyte[]putIfAbsent(String name, byte[] key, byte[] value, Duration ttl) void删除,原来是删除指定的键,目前修改为既可以删除指定键的数据,也是可以删除某个前缀开始的所有数据CompletableFuture<byte[]> Asynchronously retrieves thevalueto which themaps the given引用无效
RedisCachebyte[] keysetting theTTL expirationfor the cache entry.private static booleanStore the given key/value pair asynchronously to Redis and set the expiration time if defined.(专用程序包) voidExplicitly remove a write lock from a cache.org.springframework.data.redis.cache.RedisCacheWriterwithStatisticsCollector(org.springframework.data.redis.cache.CacheStatisticsCollector cacheStatisticsCollector) 从类继承的方法 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait从接口继承的方法 org.springframework.data.redis.cache.RedisCacheWriter
get, get, retrieve, supportsAsyncRetrieve
-
字段详细资料
-
connectionFactory
private final org.springframework.data.redis.connection.RedisConnectionFactory connectionFactory -
sleepTime
-
-
构造器详细资料
-
DefaultRedisCacheWriter
public DefaultRedisCacheWriter(org.springframework.data.redis.connection.RedisConnectionFactory connectionFactory) - 参数:
connectionFactory- must not be null.
-
DefaultRedisCacheWriter
private DefaultRedisCacheWriter(org.springframework.data.redis.connection.RedisConnectionFactory connectionFactory, Duration sleepTime) - 参数:
connectionFactory- must not be null.sleepTime- sleep time between lock request attempts. Must not be null. UseDuration.ZEROto disable locking.
-
-
方法详细资料
-
put
- 指定者:
put在接口中org.springframework.data.redis.cache.RedisCacheWriter
-
store
Store the given key/value pair asynchronously to Redis and set the expiration time if defined.This operation is non-blocking.
- 指定者:
store在接口中org.springframework.data.redis.cache.RedisCacheWriter- 参数:
name- cache name must not be null.key- key for the cache entry. Must not be null.value- value stored for the key. Must not be null.ttl- optional expiration time. Can be null.- 从以下版本开始:
- 3.2
-
get
- 指定者:
get在接口中org.springframework.data.redis.cache.RedisCacheWriter
-
retrieve
Asynchronously retrieves thevalueto which themaps the given引用无效
RedisCachebyte[] keysetting theTTL expirationfor the cache entry.This operation is non-blocking.
- 指定者:
retrieve在接口中org.springframework.data.redis.cache.RedisCacheWriter- 参数:
name-Stringwith the name of the.引用无效
RedisCachekey-byte[] keymapped to thevaluein the.引用无效
RedisCachettl-Durationspecifying the expiration timeout for the cache entry.- 返回:
- the
valueto which themaps the given引用无效
RedisCachebyte[] key. - 从以下版本开始:
- 3.2
-
putIfAbsent
- 指定者:
putIfAbsent在接口中org.springframework.data.redis.cache.RedisCacheWriter
-
remove
删除,原来是删除指定的键,目前修改为既可以删除指定键的数据,也是可以删除某个前缀开始的所有数据- 指定者:
remove在接口中org.springframework.data.redis.cache.RedisCacheWriter- 参数:
name-key-
-
clean
- 指定者:
clean在接口中org.springframework.data.redis.cache.RedisCacheWriter
-
clearStatistics
- 指定者:
clearStatistics在接口中org.springframework.data.redis.cache.RedisCacheWriter
-
withStatisticsCollector
public org.springframework.data.redis.cache.RedisCacheWriter withStatisticsCollector(org.springframework.data.redis.cache.CacheStatisticsCollector cacheStatisticsCollector) - 指定者:
withStatisticsCollector在接口中org.springframework.data.redis.cache.RedisCacheWriter
-
lock
Explicitly set a write lock on a cache.- 参数:
name- the name of the cache to lock.
-
unlock
Explicitly remove a write lock from a cache.- 参数:
name- the name of the cache to unlock.
-
doLock
-
doUnlock
-
doCheckLock
boolean doCheckLock(String name, org.springframework.data.redis.connection.RedisConnection connection) -
isLockingCacheWriter
private boolean isLockingCacheWriter()- 返回:
- true if
RedisCacheWriteruses locks.
-
execute
-
executeLockFree
private void executeLockFree(Consumer<org.springframework.data.redis.connection.RedisConnection> callback) -
checkAndPotentiallyWaitUntilUnlocked
private void checkAndPotentiallyWaitUntilUnlocked(String name, org.springframework.data.redis.connection.RedisConnection connection) -
shouldExpireWithin
-
createCacheLockKey
-
getCacheStatistics
- 指定者:
getCacheStatistics在接口中org.springframework.data.redis.cache.CacheStatisticsProvider
-