Quantcast
Channel: Active questions tagged redis+java - Stack Overflow
Viewing all articles
Browse latest Browse all 2204

Why I can't retrieve value from Redis from Spring Boot application?

$
0
0

Why I can't retrieve value from Redis from Spring Boot application?

I run Redis locally within Docker container with default port and host.I run Spring Boot application with the following setting:

    @Bean    fun reactiveRedisTemplate(lettuceConnectionFactory: ReactiveRedisConnectionFactory): ReactiveRedisTemplate<String, String> {        return ReactiveRedisTemplate<String, String>(lettuceConnectionFactory, RedisSerializationContext.string());    }

I set a value in the Redis server:

127.0.0.1:6379> set foo barOK127.0.0.1:6379> get foo"bar"127.0.0.1:6379>

And within a class I try to get the 'bar' value:

val value = reactiveRedisTemplate.opsForValue().get("foo").awaitFirstOrNull()value.subscribe{element -> println("from cache: $element")}

But unfortunately I receive null, not "bar" value as I expected.

What did I wrong?

Is it required to use @Repository etc. annotations for the operations like described above?


Viewing all articles
Browse latest Browse all 2204

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>