php redis setnx分布式锁简单原理解析
我就废话不多说了,大家还是直接看代码吧~ <?php //高并发分布式锁 header("Content-type:text/html;charset=utf-8"); $redis = new Redis(); $redis->connect('127.0.0.1', 6379); echo "Connection to server sucessfully"; //echo $redis->get("name");exit; $expire = 1; $key = 'test1'; $lock = false; $is_lock=$redis->setnx($key,time()+
用户评论