Redis流水线执行顺序

我正在使用rub redis宝石。想知道我是否例如:

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

这样的执行顺序得到保证吗?

回答:

当然可以保证顺序,否则流水线将毫无用处。您可以随时查看代码。例如,此测试明确假定命令是按顺序执行的:https :

//github.com/redis/redis-

rb/blob/master/test/pipelining_commands_test.rb#L32

def test_bulk_and_multi_bulk_commands_mixed

r.pipelined do

r.lpush "foo", "s1"

r.lpush "foo", "s2"

r.mset("baz", "s3", "qux", "s4")

end

assert_equal 2, r.llen("foo")

assert_equal "s2", r.lpop("foo")

assert_equal "s1", r.lpop("foo")

assert_equal "s3", r.get("baz")

assert_equal "s4", r.get("qux")

end

以上是 Redis流水线执行顺序 的全部内容, 来源链接: utcz.com/qa/418288.html

回到顶部