expire duration不适用于reactiveredistemplate类

4jb9z9bj  于 2021-06-10  发布在  Redis
关注(0)|答案(0)|浏览(409)

我正试图设置到期期限如下

@Bean(name="reactiveRedisTemplateForCustomer")
    public ReactiveRedisOperations<String, Object> reactiveRedisTemplateForStaticTileData(ReactiveRedisConnectionFactory reactiveRedisConnectionFactory) {

        RedisSerializationContext.RedisSerializationContextBuilder<String, Object> context =
                RedisSerializationContext.newSerializationContext(new GenericToStringSerializer<byte[]>(byte[].class));

        context.key(new StringRedisSerializer());
        context.hashKey(new StringRedisSerializer());
        context.hashValue(new JdkSerializationRedisSerializer());

        ReactiveRedisTemplate<String, Object> rt = new ReactiveRedisTemplate<>(reactiveRedisConnectionFactory, context.build());

        boolean flag = rt.expire(RedisCacheKeys.CUSTOMER, Duration.ofMillis(1500)).block(); #Refer description

        System.out.println("Expiry settings:"+ flag);
        return rt;
    }

描述:rt.expire(…),这里的值设置不正确,我尝试了block和subscribe方法,也观察到,随机将其设置为true,如果为true,则哈希[key,value]对已正确过期,但工作非常随机。

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题