关于分布式锁有很多种实现方式,可以用数据库锁或者ZooKeeper这类的专业的分布式开源项目。本文讲的是用Redis实现的一个分布式锁库python-redis-lock
. Redis官方有推荐一个分布式锁的算法Redlock(这个库实现的并不是这个算法), 该算法自动释放锁没有考虑到客户端长期持有的情况,因此也有人对这个算法提出了质疑。
那回到我们今天要讲的这个库python-redis-lock
。作者: Ionel Cristian Mărieș, 这个库整体的思路作者也用很直观的图展现出来了,如下:
Distribution Lock, Python, Redis, 分布式锁 Word Count: 3.4k(words) Read Count: 15(minutes)
Python Celery, Python, asynchronous, logging Word Count: 552(words) Read Count: 2(minutes)
杂项 BT Sync, Resilio Sync, SSH Word Count: 964(words) Read Count: 3(minutes)
Word Count: 331(words) Read Count: 1(minutes)
Python Django, Django Rest Framework, Python Word Count: 729(words) Read Count: 3(minutes)
数据相关 Data Visualization, ModeAnalytics, Python, RDS, SQL Word Count: 767(words) Read Count: 2(minutes)
AWS AWS, Aliyun, DataPipeline, RDS, RedShift Word Count: 376(words) Read Count: 1(minutes)
Python Mac, Python, pip Word Count: 549(words) Read Count: 2(minutes)
涂鸦 素描 Word Count: 4(words) Read Count: 1(minutes)
Windows MVVM, WPF, Windows, c# Word Count: 5.6k(words) Read Count: 22(minutes)
Python Django, Python Word Count: 209(words) Read Count: 1(minutes)
Python MySQLdb, Python Word Count: 390(words) Read Count: 1(minutes)