03 2021 档案

limit.php-令牌算法
摘要:0,就消耗令牌 if (local_curr_permits - permits >= 0 ) then result=1 redis.call("HMSET",key,"last_second",ARGV[1]) redis.call("HMSET",key,"curr_permits",loca 阅读全文

posted @ 2021-03-17 13:17 木林coder 阅读(76) 评论(0) 推荐(0) 编辑

分发服务器-set.lua
摘要:--写业务逻辑 local flag=ngx.shared.load:get("load") local load_blance='' if tonumber(flag) == 1 then load_blance="upstream_server_round" elseif tonumber(fl 阅读全文

posted @ 2021-03-10 18:02 木林coder 编辑

分发服务器-init.lua
摘要:--进程启动触发 local delay = 5 local handler handler = function (premature) local resty_consul = require('resty.consul') local consul = resty_consul:new({ h 阅读全文

posted @ 2021-03-10 17:57 木林coder 阅读(101) 评论(0) 推荐(0) 编辑

lock-index.php
摘要:connect("120.78.64.28",7003); //$redis->auth("sixstar"); $redis=new Lock($redis); $key='key'; $res=$redis->lock($key,3,1,10); //等待获取锁 if($res){ sleep( 阅读全文

posted @ 2021-03-10 11:08 木林coder 阅读(36) 评论(0) 推荐(0) 编辑

lock-lock.php
摘要:redis=$redis; } public function lock($key,$retry=2,$timeout=1,$ex=10){ $ok=false; $value=session_create_id(); while ( $retry-- ){ $ok=$this->redis->se 阅读全文

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

filter.lua
摘要:local ngx_re_split=require("ngx.re").split local ip_addr = ngx.shared.redis_cluster_addr:get('redis-addr') ip_addr = ngx_re_split(ip_addr,',') local r 阅读全文

posted @ 2021-03-09 20:19 木林coder 阅读(132) 评论(0) 推荐(0) 编辑

redis加载module
摘要:1内部 module load /usr/src/module/RedisBloom-2.0.3/redisbloom.so module list 2外部 redis-server /usr/src/redis/conf/redis.conf --loadmodule /usr/src/modul 阅读全文

posted @ 2021-03-09 15:30 木林coder 阅读(1039) 评论(0) 推荐(0) 编辑

redis布隆过滤器
摘要:https://github.com/RedisBloom/RedisBloom unzip redis-server /usr/src/redis/conf/redis.conf --loadmodule /usr/src/module/RedisBloom-2.0.3/redisbloom.so 阅读全文

posted @ 2021-03-08 20:46 木林coder 阅读(65) 评论(0) 推荐(0) 编辑

cache.lua--自带加锁功能方式缓存击穿
摘要:local key = ngx.re.match(ngx.var.request_uri,"/([0-9]+).html") local mlcache = require "resty.mlcache" local function fetch_shop(aaa) ngx.log(ngx.ERR, 阅读全文

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

lua-resty-mlcache
摘要:opm search mlcache opm --install-dir=/usr/local/openresty/lualib/project/common/mlcache/ get thibaultcha/lua-resty-mlcache 阅读全文

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

aapplication.lua
摘要:-- ngx.header_content_type='text/plain' --ngx.say(123) local ngx_re_split=require("ngx.re").split local ip_addr = ngx.shared.redis_cluster_addr:get('r 阅读全文

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

init.lua
摘要:local delay = 5 local handler handler = function (premature) --ngx.log(ngx.ERR," timer-do") local resty_consul = require('resty.consul') local consul 阅读全文

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

lock.lua
摘要:local rety_lock = require "resty.lock" local cache = ngx.shared.my_cache local key = ngx.re.match(ngx.var.request_uri,"/([0-9]+).html") if type(key) = 阅读全文

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

redis 开启 cluster
摘要:https://blog.csdn.net/weixin_44045802/article/details/108535569 必须开通6379和16379端口 开启集群模式 cluster-enabled yes 集群节点超时时间 cluster-node-timeout 15000 集群配置文件 阅读全文

posted @ 2021-03-06 12:44 木林coder 阅读(37) 评论(0) 推荐(0) 编辑

lua-resty-consul
摘要:yum install perl-Digest-MD5 -y opm search consul opm --install-dir=/usr/local/openresty/lualib/project/common get hamishforbes/lua-resty-consul /usr/d 阅读全文

posted @ 2021-03-04 17:32 木林coder 阅读(173) 评论(0) 推荐(0) 编辑

lua在nginx中的使用范围
摘要:https://blog.csdn.net/ygm_linux/article/details/53534933 阅读全文

posted @ 2021-03-04 17:19 木林coder 阅读(211) 评论(0) 推荐(0) 编辑

resty-redis-cluster下载地址
摘要:https://github.com/steve0511/resty-redis-cluster 阅读全文

posted @ 2021-03-03 11:24 木林coder 阅读(164) 评论(0) 推荐(0) 编辑

安装&&配置consul动态负载均衡
摘要:https://www.cnblogs.com/summerday152/p/14013439.html consul的nginx配置 upstream swoole_test { upsync 127.0.0.1:8500/v1/kv/upstreams/swoole_test upsync_ti 阅读全文

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

导航

点击右上角即可分享
微信分享提示