• 请不要在回答技术问题时复制粘贴 AI 生成的内容
imherer
V2EX  ›  程序员

redis 的 LPOP 能保证唯一性(原子性)吗?

  •  
  •   imherer · Sep 14, 2017 · 7354 views
    This topic created in 3343 days ago, the information mentioned may be changed or developed.
    假如多个程序(进程)同时操作同一个 list,能保证不产生幻读吗?(不知道这里用幻读这个词准不准备)
    7 replies  •  2017-09-15 10:07:02 +08:00
    Duolingo
    Duolingo
    Sep 14, 2017 via iPhone❤️1
    1
    redis 是单线程的,所以不会(我觉得
    flynnX
    flynnX
    Sep 14, 2017❤️1
    2
    多个进程同时操作也是分先后的,Redis 只能一次处理一个命令,不会造成不一致的情况
    imherer
    imherer
    OP
    Sep 14, 2017
    3
    @flynnX 也就是说多个进程同时 pop 同一个 list 的时候不会取到重复的数据?
    flynnX
    flynnX
    Sep 14, 2017
    4
    https://redis.io/commands/rpoplpush 可以使用这个命令

    > Atomically returns and removes the last element (tail) of the list stored at source, and pushes the element at the first element (head) of the list stored at destination.
    flynnX
    flynnX
    Sep 14, 2017❤️1
    5
    @flynnX 忽略这条

    不会读到重复的数据的
    nooper
    nooper
    Sep 14, 2017 via iPad
    6
    transactions 添加 watch
    JingKeWu
    JingKeWu
    Sep 15, 2017
    7
    用 lua 我们也是用 lua 来保证原子性 eval 函数
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   2871 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 40ms · UTC 00:46 · PVG 08:46 · LAX 16:46 · JFK 19:46
    ♥ Do have faith in what you're doing.