redis cluster环境下jedis expireAt命令bug探究

redis集群客户端JedisCluster优化 - 管道(pipeline)模式支持 redis集群客户端JedisCluster优化 - 管道(pipeline)模式支持Redis在3.0版正式引入了集群这个特性,扩展变得非常简单。然而当你开心的升级到3.0后,却发现有些很好用的功能现在工作不了了, 比如我们今天要聊的pipeline功能。 我们知道,普通的情况下,redis client与server之间采用的是请求应答的模式,即: Client: command1 阅读详情

背景

我们最近在使用spring-data-redis进行redis cluster模式测试时,发现jedis在进行expiredAt命令调用时有bug,最终调用的是pexpire命令,这个bug会导致key过期时间很长,导致redis内存溢出等问题。spring-data-redis中expiredAt命令调用栈如下:

输入图片说明输入图片说明

由于这个类属于jedis,因此升级jedis至最新(2.8.1 -> 2.9.0),依然存在此代码。在GitHub issue里我发布了关于这个问题的讨论,jedis的开发者回复确实是个bug,在jedis 2.9.1中才会解决,目前jedis 2.9.1还未发布。在这里我对该命令的代码解析了一下。

环境

jar版本: spring-data-redis-1.8.4-RELEASE.jar、jedis-2.9.0.jar

测试环境: Redis 3.2.8,八个集群节点

applicationContext-redis-cluster.xml 配置文件:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd">

	<!-- 连接池配置. -->
	<bean id="jedisPoolConfig" class="redis.clients.jedis.JedisPoolConfig">
		<!-- 连接池中最大连接数。高版本:maxTotal,低版本:maxActive -->
		<property name="maxTotal" value="8" />
		<!-- 连接池中最大空闲的连接数. -->
		<property name="maxIdle" value="4" />
		<!-- 连接池中最少空闲的连接数. -->
		<property name="minIdle" value="1" />
		<!-- 当连接池资源耗尽时,调用者最大阻塞的时间,超时将跑出异常。单位,毫秒数;默认为-1.表示永不超时。高版本:maxWaitMillis,低版本:maxWait -->
		<property name="maxWaitMillis" value="5000" />
		<!-- 连接空闲的最小时间,达到此值后空闲连接将可能会被移除。负值(-1)表示不移除. -->
		<property name="minEvictableIdleTimeMillis" value="300000" />
		<!-- 对于“空闲链接”检测线程而言,每次检测的链接资源的个数。默认为3 -->
		<property name="numTestsPerEvictionRun" value="3" />
		<!-- “空闲链接”检测线程,检测的周期,毫秒数。如果为负值,表示不运行“检测线程”。默认为-1. -->
		<property name="timeBetweenEvictionRunsMillis" value="60000" />
		<!-- testOnBorrow:向调用者输出“链接”资源时,是否检测是有有效,如果无效则从连接池中移除,并尝试获取继续获取。默认为false。建议保持默认值. -->
		<!-- testOnReturn:向连接池“归还”链接时,是否检测“链接”对象的有效性。默认为false。建议保持默认值. -->
		<!-- testWhileIdle:向调用者输出“链接”对象时,是否检测它的空闲超时;默认为false。如果“链接”空闲超时,将会被移除。建议保持默认值. -->
		<!-- whenExhaustedAction:当“连接池”中active数量达到阀值时,即“链接”资源耗尽时,连接池需要采取的手段, 默认为1(0:抛出异常。1:阻塞,直到有可用链接资源。2:强制创建新的链接资源) -->
	</bean>

	<bean id="n1" class="org.springframework.data.redis.connection.RedisNode">
		<constructor-arg value="127.0.0.1" />
		<constructor-arg value="6379" type="int" />
	</bean>
	<bean id="n2" class="org.springframework.data.redis.connection.RedisNode">
		<constructor-arg value="127.0.0.1" />
		<constructor-arg value="6380" type="int" />
	</bean>
	<bean id="n3" class="org.springframework.data.redis.connection.RedisNode">
		<constructor-arg value="127.0.0.1" />
		<constructor-arg value="6381" type="int" />
	</bean>
	
	<bean id="redisClusterConfiguration"
		class="org.springframework.data.redis.connection.RedisClusterConfiguration">
		<property name="clusterNodes">
			<set>
				<ref bean="n1" />
				<ref bean="n2" />
				<ref bean="n3" />
			</set>
		</property>
		<property name="maxRedirects" value="5" />
	</bean>

	<bean id="jedisConnectionFactory"
		class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory">
		<constructor-arg ref="redisClusterConfiguration" />
		<constructor-arg ref="jedisPoolConfig" />
	</bean>

	<!-- Spring提供的访问Redis类. -->
	<bean id="redisTemplate" class="org.springframework.data.redis.core.RedisTemplate">
		<property name="connectionFactory" ref="jedisConnectionFactory" />
		<property name="KeySerializer">
			<bean
				class="org.springframework.data.redis.serializer.StringRedisSerializer" />
		</property>
		<property name="ValueSerializer">
			<bean
				class="org.springframework.data.redis.serializer.StringRedisSerializer" />
		</property>
		<property name="hashKeySerializer">
			<bean
				class="org.springframework.data.redis.serializer.StringRedisSerializer" />
		</property>
		<property name="hashValueSerializer">
			<bean
				class="org.springframework.data.redis.serializer.StringRedisSerializer" />
		</property>
	</bean>

	<!-- Redis配置结束 -->
</beans>

相关源码解析

现在我们项目中主要使用spring-data-redis来进行redis操作,其中使用RedisTemplate,再配合jedis完成redis相关命令操作。集群环境下,关键类及实现流程如下:

redis集群配置类,负责保存集群配置:

org.springframework.data.redis.connection.RedisClusterConfiguration

redis连接工厂类,负责创建集群连接:

org.springframework.data.redis.connection.jedis.JedisConnectionFactory

集群连接Connection类,负责连接redis集群:

org.springframework.data.redis.connection.jedis.JedisClusterConnection

集群操作类,负责与redis集群进行命令交互:

redis.clients.jedis.JedisCluster

集群操作过程:

当spring容器随应用启动的时候,JedisConnectionFactory会根据RedisClusterConfiguration的配置创建redis集群的配置、连接类实例,最后使用JedisCluster类完成redis命令操作。

JedisConnectionFactory主要源码如下:

/**
 * 主要根据集群配置初始化cluster对象
 **/
public void afterPropertiesSet() {
		if (shardInfo == null) {
			shardInfo = new JedisShardInfo(hostName, port);

			if (StringUtils.hasLength(password)) {
				shardInfo.setPassword(password);
			}

			if (timeout > 0) {
				setTimeoutOn(shardInfo, timeout);
			}
		}

		if (usePool && clusterConfig == null) {
			this.pool = createPool();
		}

		//因为我们的集群配置不为空,因此这里就会创建redis.clients.jedis.JedisCluster类对象
		if (clusterConfig != null) {
			this.cluster = createCluster();
		}
	}

createCluster()源码如下:

/**
 * 创建JedisCluster对象,它负责与redis集群进行命令交互
 **/
private JedisCluster createCluster() {

		JedisCluster cluster = createCluster(this.clusterConfig, this.poolConfig);
		this.clusterCommandExecutor = new ClusterCommandExecutor(
				new JedisClusterConnection.JedisClusterTopologyProvider(cluster),
				new JedisClusterConnection.JedisClusterNodeResourceProvider(cluster), EXCEPTION_TRANSLATION);
		return cluster;
	}

从上面方法的源码我们已经看到了JedisClusterConnection类,该类在JedisConnectionFactory创建的代码如下:

/**
 * 获得JedisClusterConnection对象 
 **/
 public RedisConnection getConnection() {

		//如果JedisCluster对象不为空,则返回JedisClusterConnection对象
		if (cluster != null) {
			return getClusterConnection();
		}

		Jedis jedis = fetchJedisConnector();
		JedisConnection connection = (usePool ? new JedisConnection(jedis, pool, dbIndex, clientName)
				: new JedisConnection(jedis, null, dbIndex, clientName));
		connection.setConvertPipelineAndTxResults(convertPipelineAndTxResults);
		return postProcessConnection(connection);
	}
	
/**
 * 创建JedisClusterConnection对象 
 **/
public RedisClusterConnection getClusterConnection() {

		if (cluster == null) {
			throw new InvalidDataAccessApiUsageException("Cluster is not configured!");
		}
		return new JedisClusterConnection(cluster, clusterCommandExecutor);
	}

JedisClusterConnection类的cluster属性定义如下:

private final JedisCluster cluster;

接着我们看一下JedisCluster类中各种key过期设置的实现源码:

 @Override
  public Long expire(final String key, final int seconds) {
    return new JedisClusterCommand<Long>(connectionHandler, maxAttempts) {
      @Override
      public Long execute(Jedis connection) {
        return connection.expire(key, seconds);
      }
    }.run(key);
  }

  @Override
  public Long pexpire(final String key, final long milliseconds) {
    return new JedisClusterCommand<Long>(connectionHandler, maxAttempts) {
      @Override
      public Long execute(Jedis connection) {
        return connection.pexpire(key, milliseconds);
      }
    }.run(key);
  }

  @Override
  public Long expireAt(final String key, final long unixTime) {
    return new JedisClusterCommand<Long>(connectionHandler, maxAttempts) {
      @Override
      public Long execute(Jedis connection) {
        return connection.expireAt(key, unixTime);
      }
    }.run(key);
  }
  
   @Override
  public Long pexpireAt(final String key, final long millisecondsTimestamp) {
    return new JedisClusterCommand<Long>(connectionHandler, maxAttempts) {
      @Override
      public Long execute(Jedis connection) {
        return connection.pexpireAt(key, millisecondsTimestamp);
      }
    }.run(key);
  }

在JedisCluster类中过期操作的四个方法expire、expireAt、pexpire和pexpireAt调用的命令没有错,而它的父类BinaryJedisCluster的pexpireAt方法调用的命令是pexpire,从而导致了bug。

redisTemplate expireAt操作流程

在这里我重点分析redisTemplate expireAt操作流程以及bug产生过程。

现在我们看下redisTemplate中expireAt方法的实现:

public Boolean expireAt(K key, final Date date) {

		//获取key的字节数组
		final byte[] rawKey = rawKey(key);

		return execute(new RedisCallback<Boolean>() {

			public Boolean doInRedis(RedisConnection connection) {
				try {
					//redis 2.6以上执行该方法
					return connection.pExpireAt(rawKey, date.getTime());
				} catch (Exception e) {
					//redis 2.6以下执行该方法
					return connection.expireAt(rawKey, date.getTime() / 1000);
				}
			}
		}, true);
	}
	
        /**
          * 将key转换为字节数组
          **/
	@SuppressWarnings("unchecked")
	private byte[] rawKey(Object key) {
		Assert.notNull(key, "non null key required");
		if (keySerializer == null && key instanceof byte[]) {
			return (byte[]) key;
		}
		return keySerializer.serialize(key);
	}

在redisTemplate的expireAt方法中,有一个关键的地方:

//获取key的字节数组
final byte[] rawKey = rawKey(key);

获取key的字节数组之后,再调用RedisConnection接口的pExpireAt或expireAt方法。由于redis从3.0开始才支持集群,因此这里调用的是RedisConnection接口的pExpireAt方法。在这里RedisConnection接口的实现类是JedisClusterConnection类,它的pExpireAt方法实现如下:

        /*
	 * (non-Javadoc)
	 * @see org.springframework.data.redis.connection.RedisKeyCommands#pExpireAt(byte[], long)
	 */
	@Override
	public Boolean pExpireAt(byte[] key, long unixTimeInMillis) {

		try {
			//调用JedisCluster对象的pexpireAt方法,最终调用的是父类BinaryJedisCluster的pexpireAt方法
			return JedisConverters.toBoolean(cluster.pexpireAt(key, unixTimeInMillis));
		} catch (Exception ex) {
			throw convertJedisAccessException(ex);
		}
	}

在这里调用JedisCluster对象的pexpireAt方法时,由于key参数是字节数组类型,而JedisCluster类没有对应的pexpireAt(final byte[] key, final long millisecondsTimestamp)方法,因此会调用父类BinaryJedisCluster的pexpireAt方法,它的父类BinaryJedisCluster中pexpireAt方法的定义如下:

 @Override
  public Long pexpireAt(final byte[] key, final long millisecondsTimestamp) :
    return new JedisClusterCommand<Long>(connectionHandler, maxAttempts) {
      @Override
      public Long execute(Jedis connection) {
        // 调用的是pexpire命令而不是pexpireAt命令
        return connection.pexpire(key, millisecondsTimestamp);
      }
    }.runBinary(key);
  }

因此bug就产生了。pexpireat命令与pexpire命令都是以毫秒形式来设置key的过期时间,它们的不同如下:

命令名称说明
PEXPIRE以毫秒为单位设置 key 的生存时间
PEXPIREAT以毫秒为单位设置 key 的过期 unix 时间戳

比如我们当前使用的时间是2017/10/12 09:41:56,它的unix时间戳为1507772516000毫秒,当我们使用PEXPIREAT命令时,由于是过去的时间,相应的key会立即过期。而我们误用了PEXPIRE命令时,key不会立即过期,而是等到1507772516000毫秒后才过期,key过期时间会相当长,从而可能导致redis内存溢出、服务器崩溃等问题。

测试结果

测试及追踪源码发现,在集群环境下,使用spring-data-redis的RedisTemplate类与redis进行交互时:

  • 如果key为String类型,底层最终调用的是JedisCluster类的相关方法进行redis命令操作

  • 如果key为byte[]字节数组类型,底层最终调用的是BinaryJedisCluster类的相关方法进行redis命令操作

解决办法

在jedis 2.9.0及以下版本中,解决办法有两种,第一种是直接使用RedisTemplate类的execute方法调用expireAt命令,代码如下:

  	@Autowired
	private RedisTemplate<String, String> redisTemplate;
	
	/**
	 * 执行expireAt命令
	 */
	public void expireAt(String key, Date deadLine){
		byte[] rawKey = rawKey(key);
		redisTemplate.execute(new RedisCallback<Boolean>() {
	
			@Override
			public Boolean doInRedis(RedisConnection connection) {
				return connection.expireAt(rawKey, deadLine.getTime() / 1000);
			}
		}, true);
	}

       /**
	 * 获取key序列化方式
	 */
	@SuppressWarnings("rawtypes")
	private RedisSerializer keySerializer() {
		return redisTemplate.getKeySerializer();
	}

	/**
	 * 使用相应的key序列化方式获取key的byte[]数组
	 */
	@SuppressWarnings("unchecked")
	private byte[] rawKey(Object key) {
		if (keySerializer() == null && key instanceof byte[]) {
			return (byte[]) key;
		}
		return keySerializer().serialize(key);
	}

第二种是直接使用JedisCluster,使用JedisCluster来进行expireAt命令操作,可以参考分布式缓存技术redis学习系列(七)——spring整合jediscluster来整合JedisCluster。

问题讨论

以上就是我的整个分析过程,我已在GitHub和Stack Overflow上提交了issue,jedis的开发者已经做了回复:

Redis核心命令实战技巧与性能优化指南 Redis作为高性能内存数据库,其命令体系是开发者必须掌握的核心技能。从底层原理看,Redis通过单线程模型和内存存储实现微秒级响应,支持字符串、哈希、列表等多种数据结构。在分布式系统中,Redis的原子操作和Lua脚本特性使其成为实现分布式锁、计数器等场景的理想选择。本文重点解析KEYS、SCAN、SET等高频命令的工程实践,包括集群模式下的注意事项和性能优化技巧。通过合理使用Pipeline、批量操作和连接池,可以显著提升吞吐量。针对内存优化、延迟排查等常见问题,提供了可落地的解决方案,帮助开发者规避生 阅读详情

相关推荐

【项目实战】Redis 适配:从 4.X 到 6.X 的兼容与迁移指南

Redis 4.X到6.X版本升级适配要点:各版本在性能优化、新特性(如Stream数据结构、ACL权限控制)和安全增强(SSL/TLS)方面存在关键差异。适配需关注命令兼容性(如用UNLINK替代DEL)、配置参数调整(多线程I/O设置)、客户端版本匹配及安全特性迁移。建议分阶段升级,重点测试功能兼容性和性能表现,通过合理配置新特性实现平稳过渡,同时提升安全性和处理能力。

奶爸的编程之路,也就一周冷个三天 534

redis最佳实践

jedisCluster.incr,key值+1并返回,将 key 中储存的数字值增一,没有的先设为0再+1并返回,如果 key不存在,那么 key 的值会先被初始化为 0 ,然后再执行 INCR 操作 jedisCluster.expire,设置过期时间 jedisCluster.llen,列表长度 jedisCluster.hincrBy,把对象属性+对应数值 jedisCluster.ttl,当key不存在时,返回 -2 。 当 key 存在但没有设置剩余生存时间时,返回 -1 。否则,以秒为单位,返

qq_35572013的博客 3390

无线通信入门:3种键控法(ASK/FSK/PSK)原理图解与实战对比

本文深入解析无线通信中ASK、FSK、PSK三种基础键控法的原理与应用。通过图解对比,阐明幅移键控(ASK)简单低成本但抗干扰差,频移键控(FSK)稳健且应用广泛,相移键控(PSK)高效但复杂。文章结合实战场景,为物联网和嵌入式开发者在选型时提供关键指导,帮助平衡数据速率、成本、功耗与抗干扰需求。

weixin_29274969的博客 187

redis更新value数据时expire有效期失效

新写了一个拦截器的接口,用于防止刷接口攻击服务器的,其中有一段需要记录token访问uri的次数,当次数达到上限则拒绝服务并加入黑名单,大致逻辑如下: // Redis存储key String limitkey = "LIMIT_URI" + ":" + token + ":" + uri; int visitNum = 0; if(jedisCluster.exists(limitkey)){ visitNum = Integer.parseInt(jedisCluster.get(limitk

csdn122325735的专栏 3561

【一步到位】Android Studio 实现安卓连接阿里云物联网云平台

最新版本目前是Android Studio Iguana | 2024.1.2,你可以到官网上去找之前的版本,手上有工作项目的不要去轻易尝试,说不定你就编译失败了,失败了也不要担心,解决就可以了。

m0_73799445的博客 1万+

MQTT与物联网平台(一):基础知识和设备接入物联网平台的实现(以华为云为例)

本文简单介绍了MQTT的基础知识和使用方法,以蓝牙WIFI双模芯片W801作为硬件设备,接入到华为云。

weixin_50622833的博客 1万+

Springboot Jedis Redis集群过期时间expireAt设置问题

Jedis2.8.0到2.9.0版本有一个问题,由于在springboot-2.0.0.REALSE版本中默认使用的2.9.0的版本。pexpireAt方法中调用了pexpire方法。2.9.1版本即修复了该问题。

我的博客 663

Vensim系统动力学建模实战:从理论到仿真优化【案例详解】

本文详细介绍了Vensim在系统动力学建模中的实战应用,从基础理论到仿真优化全面解析。通过人口增长、供应链库存优化等典型案例,展示如何利用Vensim构建动态模型并进行参数优化,帮助读者掌握系统动力学建模的核心技术与实践技巧。

weixin_29231725的博客 476

无涯教程-Redis - EXPIREAT命令函数

Redis Expireat 命令用于以Unix时间戳格式设置键(key)的到期时间,过期后,键(key)将在Redis中不可用。

无涯教程 1045

【深度学习3】ubuntu22.04从零开始搭建深度学习环境

ubuntu22.04从零开始搭建深度学习开发环境

weixin_43387635的博客 1万+

数模【Mathematica(安装、入门方法、基本计算、基本图形、创建互动模型、利用数据、幻灯片演示、完整实例)】

Mathematica(安装and激活、入门方法、基本计算、基本图形、创建互动模型、利用数据、幻灯片演示、完整实例) Mathematica_11.3.0 安装教程 Mathematica11.3 激活 P1 笔记本 P2 入门方法 P3 基本计算 P4 基本图形 P5 创建互动模型 P6 利用数据 P7 演示 P8 完整实例

upward 12万+

jedis使用_Redis详细使用及结合SpringBoot

今天咱来聊一下Redis五种数据类型的详细用法以及在代码中如何使用。废话不多说,开始!Redis五种数据类型:string:字符串对象list:列表对象hash:散列set:集合zset:有序集合接下来一一进行操作(命令行操作,由于很多,就不一一截图了):一、统一操作(五种数据类型都拥有,针对key)我给定一个key:k1//获取所有key keys * //删除k1 DEL k1 //检查给定的...

weixin_39997194的博客 88

基于深度学习实现实时视频目标检测

实时视频目标检测是计算机视觉领域的研究热点之一,其应用场景包括智能监控、自动驾驶、机器人视觉等多个领域。深度学习技术的快速发展使得实时视频目标检测变得更加可行和准确。本文提出一种基于深度学习实现的实时视频目标检测系统,使用Python和OpenCV作为开发工具,具有高效、准确和实时的特点。 本系统的主要需求是实现实时视频目标检测功能,可以在不同的应用场景中使用。具体的需求如下:2.1 视频输入本系统需要从摄像头或视频文件中获取实时视频流,并对视频流中的目标进行检测和跟踪。2.2 目标检测本系统需要使用深度学

分享毕业设计的案例和论文 1940

redis常见命令,位图bitmap、redis缓存、redis集群搭建

redis常见命令,位图bitmap、redis集群搭建

weixin_52923290的博客 398

康耐视visionpro-CogBlobTool工具详细说明

康耐视visionpro-CogBlobTool工具详细说明

视觉人机器视觉的博客 1724

ET2012新版免狗免安装绿色软件

ET2012新版免狗免安祖昂绿色软件。,新界面,新视觉,

Redis 入门

本文全面介绍了Redis技术体系,从基础概念到高级应用场景,主要内容包括: NoSQL基础 对比关系型数据库的局限性 四大分类:文档型、键值型、列族型、图型数据库 Redis作为高性能键值数据库的特点 Redis核心功能 五种数据结构:String、List、Set、ZSet、Hash 持久化机制:RDB快照与AOF日志 主从复制与哨兵机制实现高可用 Cluster集群实现数据分片 开发实践 Java客户端操作指南 SpringBoot整合方案 MyBatis二级缓存实现 缓存穿透/击穿/雪崩解决方案

weixin_51689532的博客 4611

NTscan扫描工具

ntscan是一个扫描器,可以扫描没有密码和弱密码的共享,先到配置文件中填写猜测的用户名和密码,扫描过程中右侧出现的是扫描日志。

Redis高可用架构选型与核心参数调优实战

Redis高可用是指在主节点故障、网络分区或资源瓶颈等真实生产场景下,系统仍能自动完成故障检测、主从切换与数据一致性保障的能力。其技术原理涵盖哨兵的多数派选举机制、Cluster的Gossip协议与slot分片路由、Proxy模式的透明分片与配置中心协同。关键价值在于降低业务雪崩风险、缩短RTO(恢复时间目标)至秒级,并支撑电商、金融等高并发场景的稳定缓存服务。典型应用场景包括读写分离架构下的热点缓存、分布式会话存储、实时排行榜等。本文深入解析哨兵、Cluster与Proxy三大模式的适用边界,并聚焦max

clugcpne10995的博客 384

visio安装包

Microsoft Office Visio 是一款专业的制图软件。利用经过更新的形状、协作工具和数据链接图表,创建专业级图表以简化复杂的信息。

精雕软件(JDpaint) 5.5 绿色版

精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版

Redis 数据库 入门 教程

Redis 数据库入门教程

freeking101的博客 3684

redis 哨兵 异步_Redis主从同步与故障切换,有哪些坑?

在服务上线后总有些不尽人意的时候,初次使用Redis集群部署Redis主从同步出现切换故障,也是常有发生,本篇文章主要分享Redis主从同步切换有哪些坑可以尽量避免!主从数据不一致那为啥会出现这个坑呢?其实这是因为主从库间的命令复制是异步进行的。那在什么情况下,从库会滞后执行同步命令呢?一方面,主从库间的网络可能会有传输延迟,所以从库不能及时地收到主库发送的命令,从库上执行同步命令的时间就会被延后...

weixin_32570803的博客 188

在Spring Boot微服务使用JedisCluster操作Redis集群Hash哈希散列

记录:451 场景:在Spring Boot微服务使用JedisCluster操作Redis集群的Hash哈希散列数据类型。

zhangbeizhen18的博客 2083

(十)Redis集群(JedisCluster)Jedis客户端命令详解

1.echo,打印一个特定的信息 message ,测试时使用   cluster.echo("你好,echo!") 2.ping,使用客户端向 Redis 服务器发送一个 PING ,如果服务器运作正常的话,会返回一个 PONG ;通常用于测试与服务器的连接是否仍然生效,或者用于测量延迟值(注:集群不支持)     No way to dispatch this command ...

OceanSky的专栏 4608

java项目中配置redis-cluster集群的两种方式

本文分两部分: (1)jedisCluster (2)Spring-Data-Redis集群配置和RedisTemplate用法 我这里是在本机上搭建的3主3从6个redis实例。 一,jedisCluster jar引入: <dependency> <groupId>redis.clients</groupId> <artifactId>jedis</artifactId> <version>2.4.2...

2711

JedisCluster 操作API

package com.redis; import org.junit.Test; import redis.clients.jedis.HostAndPort; import redis.clients.jedis.JedisCluster; import redis.clients.jedis.JedisPoolConfig; import redis.clients.jedis.Sorti...

qq_40600507的博客 694

Jedis cluster命令执行流程剖析

面试:你懂什么是分布式系统吗?Redis分布式锁都不会?>>> ...

Viking的博客 1653
上一篇: 深入分析 Java 中的中文编码问题
下一篇: redis cluster环境下jedis expireAt命令bug探究
Viking_bird
博客等级 码龄11年 92粉丝 183原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值