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

  • 关于我们
  • 免责声明