草庐IT

redistemplate

全部标签

java - Spring RedisConnectionFactory 事务不返回到池的连接,然后在用尽时阻塞

我使用连接池创建连接工厂的配置。我确实有一个连接池。这段代码大部分是从Spring的RedisAutoConfiguration复制而来的。我出于特殊原因禁用了它。@Configuration@EnableConfigurationProperties(RedisProperties.class)publicclassJedisConfigurationimplementsRedisConfiguration{@Bean@Scope("prototype")@OverridepublicRedisConnectionFactoryconnectionFactory(RedisPrope

spring-boot - springboot redistemplate 值有\x00 数据

我使用springboot1.5.9和redis-template。但是当我保存数据到redis的时候,我发现这个值不对。看起来像这样:0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0

spring-boot - Spring RedisTemplate 重新调整有效的 Zrange 但不返回任何 key

我正在使用SpringRedisTemplate连接到Redis。我正在使用zadd添加数据,然后调用zrange来检查数据值。它返回数据很好,但是当我调用Key*时,我没有得到任何结果。真的很迷茫!!请帮忙!!但是当我运行jedis时它工作正常我看到来自cli等的条目。System.out.println("**********ZRANGEIS"+redisTemplate.zrange(patternEmailsSetKey,0l,-1l));finalSetkeys=redisTemplate.hkeys("*");System.out.println("&&&&&&&&&&&&

redis - 如何使用 RedisTemplate 存储不同的数据类型

我正在使用SpringRedisTemplate来处理与Redis相关的操作。我能存储两种数据类型吗?例如,我想存储Key、String以及Key、Integer。如何实现? 最佳答案 你读过http://docs.spring.io/spring-data/redis/docs/current/reference/html/redis.html吗??根据文档稍作改动,未经测试:publicclassExample{//injecttheactualtemplate@AutowiredprivateRedisTemplatetemp

spring - 通过 Spring redisTemplate.keys() 限制集合返回大小的任何方法

我想使用键操作从edis中搜索键。但是结果的数量在100万左右。但我只想按降序获取最多300个键。@AutowiredprivateStringRedisTemplateredisTemplate;...redisTemplate.keys("rec:*:type:3001:bill:*").stream().sorted(Collections.reverseOrder()).forEach((receivedBill)->{});;有什么方法可以限制键结果集的大小? 最佳答案 我认为您最好将键作为一组值存储到redis。因此,您

redis - spring boot 使用 redisTemplate 减少库存

我想比较mysql和redis存储中的并发递减积存量,发现springboot+redisTemplate的demo不太好找,从我在下面写的一些文档到decrstockinredis@BeanJedisConnectionFactoryjedisConnectionFactory(){returnnewJedisConnectionFactory();}@BeanRedisTemplateredisTemplate(){finalRedisTemplatetemplate=newRedisTemplate();template.setConnectionFactory(jedisCon

redis - 动态创建 RedisTemplate 以连接不同的 Redis 服务器

我的应用程序基于springboot构建,并由Redis数据存储提供支持。目前我只连接到单个redis服务器,并且该服务器的属性(主机/端口)在bootstrap.yml中定义。我想通过为每个客户使用单独的Redis服务器来支持Multi-Tenancy。为此,我需要在运行时动态连接各种不同的Redis服务器。RedisTemplate和JedisConnecitonFactory有可能吗? 最佳答案 简而言之不需要多个RedisTemplate实例;实现路由RedisConnectionFactory。说明RedisTemplat

java - 将 Lettuce 与 RedisTemplate 一起使用会抛出异常

我在运行性能测试并将它与Jedis进行比较时,试图找出为什么Lettuce给我带来这么多问题。我正在使用spring-data-redis1.8.11.RELEASE并为接口(interface)创建自定义代理bean以通过RedisTemplate访问redis。Redis在AWS中运行,我使用AWS提供的集群配置端点作为具有3个主节点和3个从节点的节点。在性能测试期间没有发生什么特别的事情。我只是调用一个使用RedisTemplate从Redis读取值的服务。使用JedisConnectionFactory时,测试总是无一异常(exception)地通过,但是当我切换到Lettuc

spring - 使用 RedisTemplate 将不同的对象迭代为 String

我在redis中有不同的模型键。我使用这些模板来存储值;publicRedisTemplatemodel1RedisTemplate(){RedisTemplateredisTemplate=newRedisTemplate();redisTemplate.setConnectionFactory(connectionFactory());redisTemplate.setKeySerializer(newStringRedisSerializer());redisTemplate.setValueSerializer(newJackson2JsonRedisSerializer(Mo

java - Spring Boot RedisTemplate 等同于 incr 方法

我曾经使用Jedis通过以下方式增加long值:Jedisjedis=newJedis();longkey=jedis.incr("myKey:");现在我正在将我的项目迁移到springboot,并将使用sprintbootRedisTemplate。但是,我找不到与RedisTemplate中的incr方法严格等效的方法。有下面一段代码,但是不一样@AutowiredprivateRedisTemplateredisTemplate;ValueOperationsops=redisTemplate.opsForValue();ops.increment("myKey:",1);是否