Multiple keys pointing to a single value in Redis (Cache) with Java

Viewed 16441

I want to store multiple keys with a single value using jedis (Redis cache) with Java.

I have three keys like user_1, driver_10, admin_5 and value = this is user, and I want to get value by using any one key among those three.

2 Answers

Here is a Lua script that can save on trafic, and pull the data in one call:

eval "return redis.call('get',redis.call('get',KEYS[1]))" 1 user-10

The above will return the request data.

Related