场景
netty内部有一个时间轮的Timer来管理大量的定时调度,例如管理心跳检测
使用方法
1 | <dependency> |
1 | public static void main(String[] args) throws InterruptedException { |
output
start:2018-06-01 18:33:41
task1 cancel :2018-06-01 18:33:56
task2 :2018-06-01 18:34:11
netty内部有一个时间轮的Timer来管理大量的定时调度,例如管理心跳检测
1 | <dependency> |
1 | public static void main(String[] args) throws InterruptedException { |
output
start:2018-06-01 18:33:41
task1 cancel :2018-06-01 18:33:56
task2 :2018-06-01 18:34:11
Apache Avro: a New Format for Data Interchange
Apache Avro™ 1.8.2 Getting Started (Java)
Apache Avro™ 1.8.2 Specification
极客时间耗子叔分布式锁
Redis分布式锁官方文档
Is Redlock safe
How to do distributed locking
加锁
SET NX 在key不存在的时候给key赋值,
PX通知 Redis 保存这个key 30000ms(锁过期时间),当资源被锁定超过过期时间时,锁自动释放
my_random_value 必须全局唯一
1 | SET resource_name my_random_value NX PX 30000 |
解锁
根据my_random_value判断是否自己持有的锁,然后执行del
1 | if redis.call("get",KEYS[1]) == ARGV[1] then |