上一页 1 ··· 6 7 8 9 10 11 12 13 14 ··· 20 下一页

2021年7月8日

nginx+lua乐观锁实现秒杀

摘要: package.path = '/class_goods/nginx/lua/5.1/lua-redis-cluster-master/?.lua;;/class_goods/nginx/lua/5.1/lua-resty-redis/lib/?.lua;;/class_goods/nginx/lu 阅读全文

posted @ 2021-07-08 10:23 木林coder 阅读(400) 评论(0) 推荐(0) 编辑

2021年7月7日

斐波那契数列-PHP

摘要: function getnum($n){ if ($n == 0) return 0; $arr = array(); $arr[2] = $arr[1] = 1; for ($i = 3; $i ⇐ $n; $i++) { $arr[$i] = $arr[$i-1] + $arr[$i-2]; } 阅读全文

posted @ 2021-07-07 21:52 木林coder 阅读(39) 评论(0) 推荐(0) 编辑

权重随机-PHP

摘要: function roll($weight = array()) { $roll = rand ( 1, array_sum ( $weight ) ); $_tmpW = 0; $rollnum = 0; foreach ( $weight as $k ⇒ $v ) { $min = $_tmpW 阅读全文

posted @ 2021-07-07 21:44 木林coder 阅读(51) 评论(0) 推荐(0) 编辑

2021年7月6日

redis主从哨兵配置

摘要: https://www.jianshu.com/p/06ab9daf921d 阅读全文

posted @ 2021-07-06 22:00 木林coder 阅读(14) 评论(0) 推荐(0) 编辑

秒杀

摘要: package.path = '/class_goods/nginx/lua/5.1/lua-redis-cluster-master/?.lua;;/class_goods/nginx/lua/5.1/lua-resty-redis/lib/?.lua;;/class_goods/nginx/lu 阅读全文

posted @ 2021-07-06 09:19 木林coder 阅读(113) 评论(0) 推荐(0) 编辑

2021年7月5日

php+redis 乐观锁

摘要: header("content-type:text/html;charset=utf-8"); $redis = new redis(); $result = $redis->connect('127.0.0.1', 6379); $mywatchkey = $redis->get(); $rob_ 阅读全文

posted @ 2021-07-05 15:48 木林coder 阅读(254) 评论(0) 推荐(0) 编辑

php+redis 分布式锁

摘要: $expire = 10; //有效期10秒 $key = 'lock'//key $value = time() + $expire//锁的值 = Unix时间戳 + 锁的有效期 $status = true; while($status) { $lock = $redis->setnx($key 阅读全文

posted @ 2021-07-05 14:59 木林coder 阅读(200) 评论(0) 推荐(0) 编辑

mysql锁

摘要: 排它锁是悲观锁的一种: select *from table where id=1 for update; 加了for update 之后其他连接无法"查询"该条数据,会超时.需要set autocommit=0; 乐观锁:比如修改库存表,表中有个字段version,两个并发连接先查询version 阅读全文

posted @ 2021-07-05 11:52 木林coder 阅读(29) 评论(0) 推荐(0) 编辑

2021年7月3日

算法复杂度

摘要: o(n) 数据增加n倍时,时间增加n倍,如遍历 o(n2) 数据增加n倍时,时间增加n2倍,如冒泡排序,需要扫描nn次 o(log2) 数据增加n倍时,时间增加log2倍,如二分查找,256个数字只需要8次就可以找到 o(nlog2) 数据增加n倍时,时间增加nlog2倍,如归并排序,当数据增大25 阅读全文

posted @ 2021-07-03 15:46 木林coder 阅读(40) 评论(0) 推荐(0) 编辑

kafka排障

摘要: /opt/kafka/bin/kafka-server-start.sh: No such file or direc https://blog.csdn.net/daziyuanazhen/article/details/106177535 阅读全文

posted @ 2021-07-03 10:34 木林coder 阅读(38) 评论(0) 推荐(0) 编辑

上一页 1 ··· 6 7 8 9 10 11 12 13 14 ··· 20 下一页

导航