分布式锁

  • 数据库加防重表(相当于复合索引);
  • 操作表时使用select ... for update,锁住行数据;
  • 使用版本号实现乐观锁;
  • 使用 redis/zookeeper 做分布式锁。