简介
说明
本文用示例介绍Redisson的用法。
Redis的客户端有RedisTemplate、Jedis、Redisson等。Redisson是最好的客户端,原因如下:
- 简单好用。
- 它实现了JDK里的List、Set、Map等接口,可以用操作JDK的类的方式操作Redis。
- 分布式锁很完美。
- 它在锁的续期、可重入、释放等处理的很好。详见:Redisson原理--分布式锁--续期/释放/互斥/可重入_IT利刃出鞘的博客-
- 功能很强大
- 支持对集合(Map、Set等)的小key设置过期时间
- 可设置集合的容量。
- 对其中元素按使用时间排序处理的方式,主动移除超过规定容量限制的元素。
- 等等
官网
官网:https://redisson.org/
git:https://github.com/redisson/redisson
git文档:https://github.com/redisson/redisson/wiki
Redisson功能
- 支持同步/异步/异步流/管道流方式连接
- 多样化数据序列化
- 集合数据分片
- 分布式对象
- 分布式集合
- 分布式锁和同步器
- 分布式服务
- 独立节点模式
- 三方框架整合
依赖
法1:使用spring-boot-starter依赖(可以在application.yml配置,很方便)
<dependency>
<groupId>org.redisson</groupId>
<artifactId>redisson-spring-boot-starter</artifactId>
<version>3.16.6</version>
</dependency>
法2:只用redisson依赖(配置很繁琐)
<dependency>
<groupId>org.redisson</groupId>
<artifactId>redisson</artifactId>
<version>3.8.2</version>
</dependency>
配置
官网
redisson-spring-boot-starter配置方案:https://github.com/redisson/redisson/tree/master/redisson-spring-boot-starter#spring-boot-starter
spring-boot-starter-data-redis配置方案:https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#application-properties.data.spring.redis.port
配置详解:https://github.com/redisson/redisson/wiki/2.-%E9%85%8D%E7%BD%AE%E6%96%B9%E6%B3%95
简介
以下方法的推荐度由高到低。
方案1:用配置文件
简介
对于配置文件方案,引入的依赖必须是redisson-spring-boot-starter;
法1:application.yml(通用配置(spring-boot-starter-data-redis))
spring:
redis:
host: 127.0.0.1
port: 6379
# password:
# database: 0 #指定数据库,默认为0
# timeout: 3000 #连接超时时间,单位毫秒,默认为0。也可以这么写:3s
# ssl: false # 是否启用SSL连接,默认false
# pool: #连接池配置
# max-active: 8 #最大活跃连接数,默认8个。
# max-idle: 8 #最大空闲连接数,默认8个。
# max-wait: -1 #获取连接的最大等待时间,默认-1,表示无限制,单位毫秒。
# #默认值可能会因为获取不到连接,导致事务无法提交,数据库被锁,大量线程处于等待状态的情况。
# min-idle: 0 #最小空闲连接数,默认0。
# sentinel:
# master: myMaster #哨兵master
# nodes: host1:port,host2:port #哨兵节点
# cluster:
# max-redirects: # 集群模式下,集群最大转发的数量
# nodes: host1:port,host2:port # 集群节点
法2:application.yml(redisson专用配置)
写法1:都写在application.yml
spring:
redis:
redisson:
config: |
clusterServersConfig:
idleConnectionTimeout: 10000
connectTimeout: 10000
timeout: 3000
retryAttempts: 3
retryInterval: 1500
failedSlaveReconnectionInterval: 3000
failedSlaveCheckInterval: 60000
password: null
subscriptionsPerConnection: 5
clientName: null
loadBalancer: !<org.redisson.connection.balancer.RoundRobinLoadBalancer> {}
subscriptionConnectionMinimumIdleSize: 1
subscriptionConnectionPoolSize: 50
slaveConnectionMinimumIdleSize: 24
slaveConnectionPoolSize: 64
masterConnectionMinimumIdleSize: 24
masterConnectionPoolSize: 64
readMode: "SLAVE"
subscriptionMode: "SLAVE"
nodeAddresses:
- "redis://127.0.0.1:7004"
- "redis://127.0.0.1:7001"
- "redis://127.0.0.1:7000"
scanInterval: 1000
pingConnectionInterval: 0
keepAlive: false
tcpNoDelay: false
threads: 16
nettyThreads: 32
codec: !<org.redisson.codec.MarshallingCodec> {}
transportMode: "NIO"
写法2:将redisson配置单独拿出来
applicaion.yml
spring:
redis:
redisson:
config: classpath:redisson.yml
redisson.yml
clusterServersConfig:
idleConnectionTimeout: 10000
connectTimeout: 10000
timeout: 3000
retryAttempts: 3
retryInterval: 1500
password: null
subscriptionsPerConnection: 5
clientName: null
loadBalancer: !<org.redisson.connection.balancer.RoundRobinLoadBalancer> {}
slaveSubscriptionConnectionMinimumIdleSize: 1
slaveSubscriptionConnectionPoolSize: 50
slaveConnectionMinimumIdleSize: 32
slaveConnectionPoolSize: 64
masterConnectionMinimumIdleSize: 32
masterConnectionPoolSize: 64
readMode: "SLAVE"
nodeAddresses:
- "redis://127.0.0.1:7004"
- "redis://127.0.0.1:7001"
- "redis://127.0.0.1:7000"
scanInterval: 1000
threads: 0
nettyThreads: 0
codec: !<org.redisson.codec.JsonJacksonCodec> {}
"transportMode":"NIO"
优先级问题
redisson配置文件优先级高于springboot配置文件优先级,比如下边这样写,则会取redisson中的配置:
spring:
redis:
host: 127.0.0.1
port: 6379
database: 0
# password: 12345
# ssl: false
# timeout: 3s
# cluster:
# nodes:
# sentinel:
# master:
# nodes:
redisson:
clusterServersConfig:
idleConnectionTimeout: 10000
connectTimeout: 10000
timeout: 3000
retryAttempts: 3
retryInterval: 1500
password: null
subscriptionsPerConnection: 5
clientName: null
loadBalancer: !<org.redisson.connection.balancer.RoundRobinLoadBalancer> {}
slaveSubscriptionConnectionMinimumIdleSize: 1
slaveSubscriptionConnectionPoolSize: 50
slaveConnectionMinimumIdleSize: 32
slaveConnectionPoolSize: 64
masterConnectionMinimumIdleSize: 32
masterConnectionPoolSize: 64
readMode: "SLAVE"
nodeAddresses:
- "redis://127.0.0.1:7004"
- "redis://127.0.0.1:7001"
- "redis://127.0.0.1:7000"
scanInterval: 1000
threads: 0
nettyThreads: 0
codec: !<org.redisson.codec.JsonJacksonCodec> {}
"transportMode":"NIO"
方案2:用代码
简介
编程中有个思路:约定大于配置大于编程。能用配置则用配置,不推荐用代码去配置。
对于配置类配置方案,引入的依赖可以是redisson-spring-boot-starter也可以是redisson。
法1:编写配置类
需要在Resource目录下创建redisson.yml。
@Configuration
public class RedssonConfig {
@Bean(destroyMethod="shutdown")
public RedissonClient redisson() throws IOException {
RedissonClient redisson = Redisson.create(
Config.fromYAML(new ClassPathResource("redisson-single.yml").getInputStream()));
return redisson;
}
}
法2:用代码配置
import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class RedissonConfig {
@Bean
public RedissonClient redissonClient() {
//指定编码,默认编码为org.redisson.codec.JsonJacksonCodec
//config.setCodec(new org.redisson.client.codec.StringCodec());
config.useSingleServer().setAddress("redis://127.0.0.1:6379");
config.useSingleServer().setClientName("root");
config.useSingleServer().setPassword("abcabc");
return Redisson.create(config);
}
}
实例
代码
package com.xiaoliu.redission.lock;
import org.redisson.api.RLock;
import org.redisson.api.RedissonClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class ShopCartController {
@Autowired
private StringRedisTemplate stringRedisTemplate;
@Autowired
private RedissonClient redissonClient;
private static final String product="MoonCake";
@GetMapping("/submitOrder")
public String submitOrder(){
RLock lock = redissonClient.getLock(product);
try {
lock.lock();//阻塞
// boolean b = lock.tryLock();//非阻塞
int stock = Integer.parseInt(stringRedisTemplate.opsForValue().get("stock"));
if (stock>0){
//下单
stock-=1;
stringRedisTemplate.opsForValue().set("stock", String.valueOf(stock));
System.out.println("扣减成功,库存stock:"+stock);
}else {
//没库存
System.out.println("扣减失败,库存不足");
}
} finally {
lock.unlock();//释放锁
}
return "end";
}
}
常用操作
获得Redisson客户端
@Autowired
private RedissonClient redissonClient;
根据key获得value
所有get开头的方法:如果key不存在会在保存时以此key为key保存。
方法 | 返回类型 |
getSet("xxx") | RSet<SomeObject> |
getList("xxx") | RList<SomeObject> |
getMap("anyMap"); | RMap<String, SomeObject> |
getSetMultimap("myMultimap"); | RSetMultimap<SimpleKey, SimpleValue> |
getSortedSet("anySet"); | RSortedSet<Integer> |
getScoredSortedSet("simple"); | RScoredSortedSet<SomeObject> |
getLexSortedSet("simple"); | RLexSortedSet set |
getQueue("anyQueue"); | RQueue<SomeObject> |
getDeque("anyDeque"); | RDeque<SomeObject> |
getBlockingQueue("anyQueue"); | BlockingQueue<SomeObject> |
getBoundedBlockingQueue("anyQueue"); | RBoundedBlockingQueue<SomeObject> |
getBlockingDeque("anyDeque"); | RBlockingDeque<Integer> |
getBlockingFairQueue("myQueue"); | RBlockingFairQueue |
getBlockingFairDeque("myDeque"); | RBlockingFairDeque |
getDelayedQueue(distinationQueue); | RDelayedQueue<String |
getPriorityQueue("anyQueue"); | RPriorityQueue<Integer> |
getPriorityDeque("anyQueue"); | RPriorityDeque<Integer> |
getPriorityBlockingQueue("anyQueue"); | RPriorityBlockingQueue<Integer> |
RPriorityBlockingDeque<Integer> | getPriorityBlockingDeque("anyQueue"); |
将key-value写回Redis
所有添加都会自动将值写回Redis。例如:
RSet<String> set = redisson.getSet("anySet");
set.add("Tony");
所有方法
过期时间
所有的类型都有过期时间,例如:
RSet<String> set = redisson.getSet("anySet");
set.add("Tony");
set.expire(3, TimeUnit.MINUTES);
过期时间在类型为空时是无效的,例如:
RSet<String> set = redisson.getSet("anySet");
set.expire(3, TimeUnit.MINUTES);
set.add("Tony");
也可以给某一个值设置过期时间
RSetCache<String> set = redisson.getSetCache("anySet");
// ttl = 10 seconds
set.add("abc", 10, TimeUnit.SECONDS);
Redis命令与Redisson方法对应
Redis command | Sync / Async Api Redisson.create(config) | Reactive Api Redisson.createReactive(config) | RxJava2 Api Redisson.createRx(config) |
AUTH | Config.setPassword() | - | - |
APPEND | RBinaryStream. getOutputStream().write() | - | - |
BZPOPMAX | RScoredSortedSet. pollLast() pollLastAsync() | RScoredSortedSetReactive. pollLast() | RScoredSortedSetRx. pollLast() |
BZPOPMIN | RScoredSortedSet. pollFirst() pollFirstAsync() | RScoredSortedSetReactive. pollFirst() | RScoredSortedSetRx. pollFirst() |
BITCOUNT | RBitSet. cardinality() cardinalityAsync() | RBitSetReactive. cardinality() | RBitSetRx. cardinality() |
BITOP | RBitSet. or() and() xor() orAsync() andAsync() xorAsync() | RBitSetReactive. or() and() xor() | RBitSetRx. or() and() xor() |
BITPOS | RBitSet. length() lengthAsync() | RBitSetReactive. length() | RBitSetRx. length() |
BLPOP | RBlockingQueue. take() poll() pollFromAny() takeAsync() pollAsync() pollFromAnyAsync() | RBlockingQueueReactive. take() poll() pollFromAny() | RBlockingQueueRx. take() poll() pollFromAny() |
BRPOP | RBlockingDeque. takeLast() takeLastAsync() | RBlockingDequeReactive. takeLast() | RBlockingDequeRx. takeLast() |
BRPOPLPUSH | RBlockingQueue. pollLastAndOfferFirstTo() pollLastAndOfferFirstToAsync() | RBlockingQueueReactive. pollLastAndOfferFirstTo() | RBlockingQueueRx. pollLastAndOfferFirstTo() |
CONFIG GET | RedisNode. setConfig() setConfigAsync() | - | - |
CONFIG SET | RedisNode. getConfig() getConfigAsync() | - | - |
COPY | RObject. copy() copyAsync() | RObjectReactive. copy() | RObjectRx. copy() |
CLIENT SETNAME | Config.setClientName() | - | - |
CLIENT REPLY | BatchOptions.skipResult() | - | - |
CLUSTER INFO | ClusterNode.info() | - | - |
CLUSTER KEYSLOT | RKeys. getSlot() getSlotAsync() | RKeysReactive. getSlot() | RKeysRx. getSlot() |
CLUSTER NODES | Used in ClusterConnectionManager | ||
DECRBY | RAtomicLong. addAndGet() addAndGetAsync() | RAtomicLongReactive. addAndGet() | RAtomicLongRx. addAndGet() |
DUMP | RObject. dump() dumpAsync() | RObjectReactive. dump() | RObjectRx. dump() |
DBSIZE | RKeys. count() countAsync() | RKeysReactive. count() | RKeysRx.count() |
DECR | RAtomicLong. decrementAndGet() decrementAndGetAsync() | RAtomicLongReactive. decrementAndGet() | RAtomicLongRx. decrementAndGet() |
DEL | RObject. delete() deleteAsync() RKeys. delete() deleteAsync() | RObjectReactive. delete() RKeysReactive. delete() | RObjectRx. delete() RKeysRx. delete() |
STRLEN | RBucket. size() sizeAsync() | RBucketReactive. size() | RBucketRx. size() |
EVAL | RScript. eval() evalAsync() | RScriptReactive. eval() | RScriptRx. eval() |
EVALSHA | RScript. evalSha() evalShaAsync() | RScriptReactive. evalSha() | RScriptRx. evalSha() |
EXEC | RBatch. execute() executeAsync() | RBatchReactive. execute() | RBatchRx. execute() |
EXISTS | RObject. isExists() isExistsAsync() | RObjectReactive. isExists() | RObjectRx. isExists() |
FLUSHALL | RKeys. flushall() flushallAsync() | RKeysReactive. flushall() | RKeysRx. flushall() |
FLUSHDB | RKeys. flushdb() flushdbAsync() | RKeysReactive. flushdb() | RKeysRx. flushdb() |
GETRANGE | RBinaryStream. getChannel().read() | RBinaryStreamReactive. read() | RBinaryStreamRx. read() |
GEOADD | RGeo. add() addAsync() | RGeoReactive. add() | RGeoRx. add() |
GEODIST | RGeo. dist() distAsync() | RGeoReactive. dist() | RGeoRx. dist() |
GEOHASH | RGeo. hash() hashAsync() | RGeoReactive. hash() | RGeoRx. hash() |
GEOPOS | RGeo. pos() posAsync() | RGeoReactive. pos() | RGeoRx. pos() |
GEORADIUS | RGeo. radius() radiusAsync() radiusWithDistance() radiusWithDistanceAsync() radiusWithPosition() radiusWithPositionAsync() | RGeoReactive. radius() radiusWithDistance() radiusWithPosition() | RGeoRx. radius() radiusWithDistance() radiusWithPosition() |
GET | RBucket. get() getAsync() RBinaryStream. get() getAsync() | RBucketReactive. get() RBinaryStreamReactive. get() | RBucketRx. get() RBinaryStreamRx. get() |
GETBIT | RBitSet. get() getAsync() | RBitSetReactive. get() | RBitSetRx. get() |
GETSET | RBucket. getAndSet() getAndSetAsync() RAtomicLong. getAndSet() getAndSetAsync() RAtomicDouble. getAndSet() getAndSetAsync() | RBucketReactive. getAndSet() RAtomicLongReactive. getAndSet() RAtomicDoubleReactive. getAndSet() | RBucketRx. getAndSet() RAtomicLongRx. getAndSet() RAtomicDoubleRx. getAndSet() |
HDEL | RMap. fastRemove() fastRemoveAsync() | RMapReactive. fastRemove() | RMapRx. fastRemove() |
HEXISTS | RMap. containsKey() containsKeyAsync() | RMapReactive. containsKey() | RMapRx. containsKey() |
HGET | RMap. get() getAsync() | RMapReactive. get() | RMapRx. get() |
HSTRLEN | RMap. valueSize() valueSizeAsync() | RMapReactive. valueSize() | RMapRx. valueSize() |
HGETALL | RMap. readAllEntrySet() readAllEntrySetAsync() | RMapReactive. readAllEntrySet() | RMapRx. readAllEntrySet() |
HINCRBY | RMap. addAndGet() addAndGetAsync() | RMapReactive. addAndGet() | RMapRx. addAndGet() |
HINCRBYFLOAT | RMap. addAndGet() addAndGetAsync() | RMapReactive. addAndGet() | RMapRx. addAndGet() |
HKEYS | RMap. readAllKeySet() readAllKeySetAsync() | RMapReactive. readAllKeySet() | RMapRx. readAllKeySet() |
HLEN | RMap. size() sizeAsync() | RMapReactive. size() | RMapRx. size() |
HMGET | RMap. getAll() getAllAsync() | RMapReactive. getAll() | RMapRx. getAll() |
HMSET | RMap. putAll() putAllAsync() | RMapReactive. putAll() | RMapRx. putAll() |
HSCAN | RMap. keySet().iterator() values().iterator() entrySet().iterator() | RMapReactive. keyIterator() valueIterator() entryIterator() | RMapRx. keyIterator() valueIterator() entryIterator() |
HSET | RMap. fastPut() fastPutAsync() | RMapReactive. fastPut() | RMapRx. fastPut() |
HSETNX | RMap. fastPutIfAbsent() fastPutIfAbsentAsync() | RMapReactive. fastPutIfAbsent() | RMapRx. fastPutIfAbsent() |
HVALS | RMap. readAllValues() readAllValuesAsync() | RMapReactive. readAllValues() | RMapRx. readAllValues() |
INCR | RAtomicLong. incrementAndGet() incrementAndGetAsync() | RAtomicLongReactive. incrementAndGet() | RAtomicLongRx. incrementAndGet() |
INCRBY | RAtomicLong. addAndGet() addAndGetAsync() | RAtomicLongReactive. addAndGet() | RAtomicLongRx. addAndGet() |
INCRBYFLOAT | RAtomicDouble. addAndGet() addAndGetAsync() | RAtomicDoubleReactive. addAndGet() | RAtomicDoubleRx. addAndGet() |
KEYS | RKeys. getKeysByPattern() getKeysByPatternAsync() | RKeysReactive. getKeysByPattern() | RKeysRx. getKeysByPattern() |
LINDEX | RList. get() getAsync() | RListReactive. get() | RListRx. get() |
LLEN | RList. size() sizeAsync() | RListReactive. size() | RListRx. size() |
LPOP | RQueue. poll() pollAsync() | RQueueReactive. poll() | RQueueRx. poll() |
LPUSH | RDeque. addFirst() addFirstAsync() | RDequeReactive. addFirst() | |
LRANGE | RList. readAll() readAllAsync() | RListReactive.readAll() | RListRx.readAll() |
LPUSHX | RDeque. addFirstIfExists() addFirstIfExistsAsync() | RDequeReactive. addFirstIfExists() | RDequeRx. addFirstIfExists() |
LREM | RList. fastRemove() fastRemoveAsync() | RListReactive. fastRemove() | RListRx. fastRemove() |
LSET | RList. fastSet() fastSetAsync() | RListReactive. fastSet() | RListRx. fastSet() |
LTRIM | RList. trim() trimAsync() | RListReactive. trim() | RListRx. trim() |
LINSERT | RList. addBefore() addAfter() addBeforeAsync() addAfterAsync() | RListReactive. addBefore() addAfter() | RListRx. addBefore() addAfter() |
MULTI | RBatch. execute() executeAsync() | RBatchReactive. execute() | RBatchRx. execute() |
MGET | RBuckets. get() getAsync() | RBucketsReactive. get() | RBucketsRx. get() |
MSETNX | RBuckets. trySet() trySetAsync() | RBucketsReactive. trySet() | RBucketsRx. trySet() |
MIGRATE | RObject. migrate() migrateAsync() | RObjectReactive. migrate() | RObjectRx. migrate() |
MOVE | RObject. move() moveAsync() | RObjectReactive. move() | RObjectRx. move() |
MSET | RBuckets. set() setAsync() | RBucketsReactive. set() | RBucketsRx. set() |
PERSIST | RExpirable. clearExpire() clearExpireAsync() | RExpirableReactive. clearExpire() | RExpirableRx. clearExpire() |
PEXPIRE | RExpirable. expire() expireAsync() | RExpirableReactive. expire() | RExpirableRx. expire() |
PEXPIREAT | RExpirable. expireAt() expireAtAsync() | RExpirableReactive. expireAt() | RExpirableRx. expireAt() |
PFADD | RHyperLogLog. add() addAsync() addAll() addAllAsync() | RHyperLogLogReactive. add() addAll() | RHyperLogLogRx. add() addAll() |
PFCOUNT | RHyperLogLog. count() countAsync() countWith() countWithAsync() | RHyperLogLogReactive. count() countWith() | RHyperLogLogRx. count() countWith() |
PFMERGE | RHyperLogLog. mergeWith() mergeWithAsync() | RHyperLogLogReactive. mergeWith() | RHyperLogLogRx. mergeWith() |
PING | Node.ping() NodesGroup.pingAll() | - | - |
PSUBSCRIBE | RPatternTopic. addListener() | RPatternTopicReactive. addListener() | RPatternTopicRx. addListener() |
PSETEX | RBucket. set() setAsync() | RBucketReactive. set() | RBucketRx. set() |
PTTL | RExpirable. remainTimeToLive() remainTimeToLiveAsync() | RExpirableReactive. remainTimeToLive() | RExpirableRx. remainTimeToLive() |
PUBLISH | RTopic. publish() | RTopicReactive. publish() | RTopicRx. publish() |
PUBSUB NUMSUB | RTopic. countSubscribers() countSubscribersAsync() | RTopicReactive. countSubscribers() | RTopicRx. countSubscribers() |
PUNSUBSCRIBE | RPatternTopic. removeListener() | RPatternTopicReactive. removeListener() | RPatternTopicRx. removeListener() |
RANDOMKEY | RKeys. randomKey() randomKeyAsync() | RKeysReactive. randomKey() | RKeysRx. randomKey() |
RESTORE | RObject. restore() restoreAsync() | RObjectReactive. restore() | RObjectRx. restore() |
RENAME | RObject. rename() renameAsync() | RObjectReactive. rename() | RObjectRx. rename() |
RPOP | RDeque. pollLast() removeLast() pollLastAsync() removeLastAsync() | RDequeReactive. pollLast() removeLast() | RDequeRx. pollLast() removeLast() |
RPOPLPUSH | RDeque. pollLastAndOfferFirstTo() pollLastAndOfferFirstToAsync() | RDequeReactive. pollLastAndOfferFirstTo() | RDequeRx. pollLastAndOfferFirstTo() |
RPUSH | RList. add() addAsync() | RListReactive. add() | RListRx. add() |
RPUSHX | RDeque. addLastIfExists() addLastIfExistsAsync() | RListReactive. addLastIfExists() | RListRx. addLastIfExists() |
SADD | RSet. add() addAsync() | RSetReactive. add() | RSetRx. add() |
SETRANGE | RBinaryStream. getChannel().write() | RBinaryStreamReactive. write() | RBinaryStreamRx. write() |
SCAN | RKeys. getKeys() | RKeysReactive. getKeys() | RKeysRx. getKeys() |
SCARD | RSet. size() sizeAsync() | RSetReactive. size() | RSetRx. size() |
SCRIPT EXISTS | RScript. scriptExists() scriptExistsAsync() | RScriptReactive. scriptExists() | RScriptRx. scriptExists() |
SCRIPT FLUSH | RScript. scriptFlush() scriptFlushAsync() | RScriptReactive. scriptFlush() | RScriptRx. scriptFlush() |
SCRIPT KILL | RScript. scriptKill() scriptKillAsync() | RScriptReactive. scriptKill() | RScriptRx. scriptKill() |
SCRIPT LOAD | RScript. scriptLoad() scriptLoadAsync() | RScriptReactive. scriptLoad() | RScriptRx. scriptLoad() |
SDIFFSTORE | RSet. diff() diffAsync() | RSetReactive. diff() | RSetRx. diff() |
SDIFF | RSet. readDiff() readDiffAsync() | RSetReactive. readDiff() | RSetRx. readDiff() |
SRANDMEMBER | RSet. random() randomAsync() | RSetReactive. random() | RSetRx. random() |
SELECT | Config.setDatabase() | - | - |
SET | RBucket. set() setAsync() | RBucketReactive. set() | RBucketRx. set() |
SETBIT | RBitSet. set() clear() setAsync() clearAsync() | RBitSetReactive. set() clear() | RBitSetRx. set() clear() |
SETEX | RBucket. set() setAsync() | RBucketReactive. set() | RBucketRx. set() |
SETNX | RBucket. trySet() trySetAsync() | RBucketReactive. trySet() | RBucketRx. trySet() |
SISMEMBER | RSet. contains() containsAsync() | RSetReactive. contains() | RSetRx. contains() |
SINTERSTORE | RSet. intersection() intersectionAsync() | RSetReactive. intersection() | RSetRx. intersection() |
SINTER | RSet. readIntersection() readIntersectionAsync() | RSetReactive. readIntersection() | RSetRx. readIntersection() |
SMEMBERS | RSet. readAll() readAllAsync() | RSetReactive. readAll() | RSetRx. readAll() |
SMOVE | RSet. move() moveAsync() | RSetReactive. move() | RSetRx. move() |
SORT | RList. readSort() sortTo() readSortAsync() sortToAsync() | RListReactive. readSort() sortTo() | RListRx. readSort() sortTo() |
SPOP | RSet. removeRandom() removeRandomAsync() | RSetReactive. removeRandom() | RSetRx. removeRandom() |
SREM | RSet. remove() removeAsync() | RSetReactive. remove() | RSetRx. remove() |
SSCAN | RSet. iterator() | RSetReactive. iterator() | RSetRx. iterator() |
SUBSCRIBE | RTopic. addListener() | RTopicReactive. addListener() | RTopicRx. addListener() |
SUNION | RSet. readUnion() readUnionAsync() | RSetReactive. readUnion() | RSetRx. readUnion() |
SUNIONSTORE | RSet. union() unionAsync() | RSetReactive. union() | RSetRx. union() |
SWAPDB | RKeys. swapdb() swapdbAsync() | RKeysReactive. swapdb() | RKeysRx. swapdb() |
TTL | RExpirable. remainTimeToLive() remainTimeToLiveAsync() | RExpirableReactive. remainTimeToLive() | RExpirableRx. remainTimeToLive() |
TYPE | RKeys. getType() getTypeAsync() | RKeysReactive. getType() | RKeysRx. getType() |
TOUCH | RObject. touch() touchAsync() | RObjectReactive. touch() | RObjectRx. touch() |
UNSUBSCRIBE | RTopic. removeListener() | RTopicReactive. removeListener() | RTopicRx. removeListener() |
UNLINK | RObject. unlink() unlinkAsync() | RObjectReactive. unlink() | RObjectRx. unlink() |
WAIT | BatchOptions. syncSlaves() | BatchOptions. syncSlaves() | BatchOptions. syncSlaves() |
ZADD | RScoredSortedSet. add() addAsync() | RScoredSortedSetReactive. add() | RScoredSortedSetRx. add() |
ZCARD | RScoredSortedSet. size() sizeAsync() | RScoredSortedSetReactive. size() | RScoredSortedSetRx. size() |
ZCOUNT | RScoredSortedSet. count() countAsync() | RScoredSortedSetReactive. count() | RScoredSortedSetRx. count() |
ZINCRBY | RScoredSortedSet. addScore() addScoreAsync() | RScoredSortedSetReactive. addScore() | RScoredSortedSetRx. addScore() |
ZREMRANGEBYRANK | RScoredSortedSet. removeRangeByRank() removeRangeByRankAsync() | RScoredSortedSetReactive. removeRangeByRank() | RScoredSortedSetRx. removeRangeByRank() |
ZREVRANGEBYLEX | RLexSortedSet. rangeReversed() rangeReversedAsync() | RLexSortedSetReactive. rangeReversed() | RLexSortedSetSetRx. rangeReversed() |
ZLEXCOUNT | RLexSortedSet. lexCount() lexCountHead() lexCountTail() lexCountAsync() lexCountHeadAsync() lexCountTailAsync() | RLexSortedSetReactive. lexCount() lexCountHead() lexCountTail() | RLexSortedSetRx. lexCount() lexCountHead() lexCountTail() |
ZRANGE | RScoredSortedSet. valueRange() valueRangeAsync() | RScoredSortedSetReactive. valueRange() | RScoredSortedSetRx. valueRange() |
ZREVRANGE | RScoredSortedSet. valueRangeReversed() valueRangeReversedAsync() | RScoredSortedSetReactive. valueRangeReversed() | RScoredSortedSetRx. valueRangeReversed() |
ZUNIONSTORE | RScoredSortedSet. union() unionAsync() | RScoredSortedSetReactive. union() | RScoredSortedSetRx. union() |
ZINTERSTORE | RScoredSortedSet. intersection() intersectionAsync() | RScoredSortedSetReactive. intersection() | RScoredSortedSetRx. intersection() |
ZRANGEBYLEX | RLexSortedSet. range() rangeHead() rangeTail() rangeAsync() rangeHeadAsync() rangeTailAsync() | RLexSortedSetReactive. range() rangeHead() rangeTail() | RLexSortedSetRx. range() rangeHead() rangeTail() |
ZRANGEBYSCORE | RScoredSortedSet. valueRange() entryRange() valueRangeAsync() entryRangeAsync() | RScoredSortedSetReactive. valueRange() entryRange() | RScoredSortedSetRx. valueRange() entryRange() |
TIME | RedissonClient. getNodesGroup(). getNode().time() getClusterNodesGroup(). getNode().time() | - | - |
ZRANK | RScoredSortedSet. rank() rankAsync() | RScoredSortedSetReactive. rank() | RScoredSortedSetRx. rank() |
ZREM | RScoredSortedSet. remove() removeAll() removeAsync() removeAllAsync() | RScoredSortedSetReactive. remove() removeAll() | RScoredSortedSetRx. remove() removeAll() |
ZREMRANGEBYLEX | RLexSortedSet. removeRange() removeRangeHead() removeRangeTail() removeRangeAsync() removeRangeHeadAsync() removeRangeTailAsync() | RLexSortedSetReactive. removeRange() removeRangeHead() removeRangeTail() | RLexSortedSetRx. removeRange() removeRangeHead() removeRangeTail() |
ZREMRANGEBYSCORE | RScoredSortedSet. removeRangeByScore() removeRangeByScoreAsync() | RScoredSortedSetReactive. removeRangeByScore() | RScoredSortedSetRx. removeRangeByScore() |
ZREVRANGEBYSCORE | RScoredSortedSet. valueRangeReversed() entryRangeReversed() valueRangeReversedAsync() entryRangeReversedAsync() | RScoredSortedSetReactive. entryRangeReversed() valueRangeReversed() | RScoredSortedSetRx. entryRangeReversed() valueRangeReversed() |
ZREVRANK | RScoredSortedSet. revRank() revRankAsync() | RScoredSortedSetReactive. revRank() | RScoredSortedSetRx. revRank() |
ZSCORE | RScoredSortedSet. getScore() getScoreAsync() | RScoredSortedSetReactive. getScore() | RScoredSortedSetRx. getScore() |
ZPOPMAX | RScoredSortedSet. pollLast() pollLastAsync() | RScoredSortedSetReactive. pollLast() | RScoredSortedSetRx. pollLast() |
ZPOPMIN | RScoredSortedSet. pollFirst() pollFirstAsync() | RScoredSortedSetReactive. pollFirst() | RScoredSortedSetRx. pollFirst() |
XACK | RStream. ack() ackAsync() | RStreamReactive. ack() | RStreamRx. ack() |
XADD | RStream. add() addAsync() | RStreamReactive. add() | RStreamRx. add() |
XCLAIM | RStream. claim() claimAsync() | RStreamReactive. claim() | RStreamRx. claim() |
XDEL | RStream. remove() removeAsync() | RStreamReactive. remove() | RStreamRx. remove() |
XGROUP | RStream. createGroup() removeGroup() updateGroup() createGroupAsync() removeGroupAsync() updateGroupAsync() | RStreamReactive. createGroup() removeGroup() updateGroup() | RStreamRx. createGroup() removeGroup() updateGroup() |
XINFO | RStream. getInfo() listGroups() listConsumers() getInfoAsync() listGroupsAsync() listConsumersAsync() | RStreamReactive. getInfo() listGroups() listConsumers() | RStreamRx. getInfo() listGroups() listConsumers() |
XLEN | RStream. size() sizeAsync() | RStreamReactive. size() | RStreamRx. size() |
XPENDING | RStream. listPending() listPendingAsync() | RStreamReactive. listPending() | RStreamRx. listPending() |
XRANGE | RStream. range() rangeAsync() | RStreamReactive. range() | RStreamRx. range() |
XREAD | RStream. read() readAsync() | RStreamReactive. read() | RStreamRx. read() |
XREADGROUP | RStream. readGroup() readGroupAsync() | RStreamReactive. readGroup() | RStreamRx. readGroup() |
XREVRANGE | RStream. rangeReversed() rangeReversedAsync() | RStreamReactive. rangeReversed() | RStreamRx. rangeReversed() |
XTRIM | RStream. trim() trimAsync() | RStreamReactive. trim() | RStreamRx. trim() |
其他网址
最简单的spring-boot-starter-redisson发布啦! | 纳兰小筑
2-(1)、SpringBoot整合redisson实现分布式锁 -