Java 类org.springframework.data.redis.core.ReactiveRedisTemplate 实例源码

项目:spring-cloud-gateway    文件:GatewayRedisAutoConfiguration.java   
@Bean
//TODO: replace with ReactiveStringRedisTemplate in future
public ReactiveRedisTemplate<String, String> stringReactiveRedisTemplate(
        ReactiveRedisConnectionFactory reactiveRedisConnectionFactory,
        ResourceLoader resourceLoader) {
    RedisSerializer<String> serializer = new StringRedisSerializer();
    RedisSerializationContext<String , String> serializationContext = RedisSerializationContext
            .<String, String>newSerializationContext()
            .key(serializer)
            .value(serializer)
            .hashKey(serializer)
            .hashValue(serializer)
            .build();
    return new ReactiveRedisTemplate<>(reactiveRedisConnectionFactory,
            serializationContext);
}
项目:spring-session    文件:IndexDocTests.java   
@Test
@SuppressWarnings("unused")
public void newReactiveRedisOperationsSessionRepository() {
    LettuceConnectionFactory connectionFactory = new LettuceConnectionFactory();
    RedisSerializationContext<String, Object> serializationContext = RedisSerializationContext
            .<String, Object>newSerializationContext(
                    new JdkSerializationRedisSerializer())
            .build();

    // tag::new-reactiveredisoperationssessionrepository[]
    // ... create and configure connectionFactory and serializationContext ...

    ReactiveRedisTemplate<String, Object> redisTemplate = new ReactiveRedisTemplate<>(
            connectionFactory, serializationContext);

    ReactiveSessionRepository<? extends Session> repository =
            new ReactiveRedisOperationsSessionRepository(redisTemplate);
    // end::new-reactiveredisoperationssessionrepository[]
}
项目:spring-reactive-sample    文件:DemoApplication.java   
@Bean
public ReactiveRedisTemplate<String, Post> reactiveJsonPostRedisTemplate(
    ReactiveRedisConnectionFactory connectionFactory) {

    RedisSerializationContext<String, Post> serializationContext = RedisSerializationContext
        .<String, Post>newSerializationContext(new StringRedisSerializer())
        .hashKey(new StringRedisSerializer())
        .hashValue(new Jackson2JsonRedisSerializer<>(Post.class))
        .build();


    return new ReactiveRedisTemplate<>(connectionFactory, serializationContext);
}
项目:spring-session    文件:RedisWebSessionConfiguration.java   
private ReactiveRedisTemplate<String, Object> createReactiveRedisTemplate() {
    RedisSerializer<String> keySerializer = new StringRedisSerializer();
    RedisSerializer<Object> valueSerializer = new JdkSerializationRedisSerializer(
            this.classLoader);
    RedisSerializationContext<String, Object> serializationContext = RedisSerializationContext
            .<String, Object>newSerializationContext(valueSerializer)
            .key(keySerializer).hashKey(keySerializer).build();
    return new ReactiveRedisTemplate<>(this.redisConnectionFactory,
            serializationContext);
}
项目:spring-cloud-gateway    文件:GatewayRedisAutoConfiguration.java   
@Bean
public RedisRateLimiter redisRateLimiter(ReactiveRedisTemplate<String, String> redisTemplate,
                                         @Qualifier("redisRequestRateLimiterScript") RedisScript<List<Long>> redisScript) {
    return new RedisRateLimiter(redisTemplate, redisScript);
}
项目:spring-cloud-gateway    文件:RedisRateLimiter.java   
public RedisRateLimiter(ReactiveRedisTemplate<String, String> redisTemplate,
        RedisScript<List<Long>> script) {
    this.redisTemplate = redisTemplate;
    this.script = script;
}