I want to implement a tag cloud.
Tag information is stored in Redis:
redisTemplate.opsForValue().set(tagKey, tagName);
The usage count of the tags is also stored in Redis, using a sorted set:
redisTemplate.opsForZSet().incrementScore(TAG_CLOUD_KEY, tagKey, 1);
My question is that when showing the tag cloud, I want to show the tagName. However, when retrieving the tag usage count via TAG_CLOUD_KEY, I can only get the tagKey. How can I match tagKeys with ralative tagNames, how can I design the storage structure in Redis to meet this requirement?
I don’t want to loop through all the tag keys to get the tagName via the tagKey, as this seems very inefficient. What is the best practice in Redis for such key-name matching problem?
Ted Han Neversummer is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.