lundi 30 mars 2015

what is 'hashKey' in HashOperations of 'Spring Data Redis'

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:


http://ift.tt/1BZdH1x


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:



  1. Object -> byte[]

  2. or Object -> Json String -> byte[]


  3. or use hmset, e.g.



    hmset [userId] name [name] address [address]



Thank you.


Aucun commentaire:

Enregistrer un commentaire