I saw someone use 'redisTemplate.opsForHash' like this:
User user = ...
String key = user.getUserId();
redisTemplate.opsForHash().put(key, key.hashCode(), value);
and I found the API:
but I don't know what is 'key.hashCode' used for.
And I want to know which is better to store a Object to redis:
- Object -> byte[]
- or Object -> Json String -> byte[]
or use hmset, e.g.
hmset [userId] name [name] address [address]
Thank you.
Aucun commentaire:
Enregistrer un commentaire