logo
  • 教程列表
  • SO官方文檔
  • 使用 Python 連線到 redis
    • 新增元素到列表
    • 將欄位新增到雜湊
    • 設定與 Redis 的連線
    • 建立交易
    • 直接執行命令
  1. StackOverflow 文件
  2. redis 教程
  3. 使用 Python 連線到 redis
  4. 建立交易

建立交易

Created: November-22, 2018

你可以通過呼叫 StrictRedis 上的 pipeline 方法來建立事務。針對事務執行的 Redis 命令在單個塊中執行。

# defaults to transaction=True 
tx = r.pipeline()
tx.hincrbyfloat(debit_account_key, 'balance', -amount)
tx.hincrbyfloat(credit_account_key, 'balance', amount)
tx.execute()
  • 直接執行命令
  • 設定與 Redis 的連線

Copyright © 2018. All right reserved

tastones.com 备案号:鲁ICP备18045372号-1

  • 關於本站
  • 免責聲明