I am using rub redis gem. Wondering if I do for example:
redis.pipelined do
REDIS.del("users:#{current_user_id}:i-unread")
REDIS.lpush("users:#{current_user_id}:i-read", items)
REDIS.ltrim("users:#{current_user_id}:i-read", 0, Interaction::MAX_INTERACTIONS)
end
is this order of execution guaranteed?
of course the order is guaranteed, otherwise pipelining would be useless. you can always look at the code. for example, this test clearly assumes that the commands are executed sequentially: https://github.com/redis/redis-rb/blob/master/test/pipelining_commands_test.rb#L32
Yes, it is guaranteed. Generally, redis pipelining is nothing more complicated than queuing server responses in memory, so it does not change the order of queries.