Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01B38FGKKam5SCGgwgduVAh3
46 lines
1.0 KiB
Plaintext
46 lines
1.0 KiB
Plaintext
# StringRedisTemplate: every key and value is UTF-8 text
|
|
|
|
|
|
--- Which serializers is it using? ---
|
|
key serializer: StringRedisSerializer
|
|
value serializer: StringRedisSerializer
|
|
hash key serializer: StringRedisSerializer
|
|
hash value serializer: StringRedisSerializer
|
|
|
|
--- A string value ---
|
|
stringTemplate.opsForValue().set("user:1", "Ankur")
|
|
$ redis-cli -p 6390 --no-raw GET user:1
|
|
"Ankur"
|
|
|
|
--- A counter ---
|
|
stringTemplate.opsForValue().increment("hits") twice = 2
|
|
$ redis-cli -p 6390 --no-raw GET hits
|
|
"2"
|
|
|
|
--- A hash ---
|
|
stringTemplate.opsForHash().put("user:1:profile", "city", "Pune") and ("editor", "vim")
|
|
$ redis-cli -p 6390 --no-raw HGETALL user:1:profile
|
|
1) "city"
|
|
2) "Pune"
|
|
3) "editor"
|
|
4) "vim"
|
|
|
|
--- A list, a set and a sorted set ---
|
|
$ redis-cli -p 6390 --no-raw LRANGE queue 0 -1
|
|
1) "a"
|
|
2) "b"
|
|
3) "c"
|
|
$ redis-cli -p 6390 SMEMBERS tags | sort
|
|
java
|
|
spring
|
|
$ redis-cli -p 6390 --no-raw ZRANGE scores 0 -1 WITHSCORES
|
|
1) "ankur"
|
|
2) "42"
|
|
$ redis-cli -p 6390 KEYS '*' | sort
|
|
hits
|
|
queue
|
|
scores
|
|
tags
|
|
user:1
|
|
user:1:profile
|