Redis Future + Rails

redis, ruby-on-rails

Solution

Future objects are typically returned when methods are called in a pipeline or a transaction.

The returned value is only available when the EXEC command has been applied to the Redis server. With redis-rb, it means you should exit a pipelined or multi block before.

If you want to select/read data, do it before the multi/exec block, and do only write in the multi/exec block.

By the way, it will be more efficient to use $redis.sunion() to generate the result on server-side.

Problem

I am using redis in one of my rails project where I tried to union the sets of redis like ``` $redis.smembers('set1') | $redis.smembers('set2') ``` but it throws error like this ``` undefined method `|' for #<Redis::Future:0x000001306e5830> ``` What is `Redis::Future`? I am using redis and redis-store gems Thank you

Original source