上一页 1 ··· 4 5 6 7 8 9 10 11 12 ··· 34 下一页
摘要: 当redis设置了密码时代码如下:[root@node5 lua]# cat /usr/local/lua/access_by_limit_ip.lua 用户redis客户端设置:添加黑名单IP:sadd limit:ip:blacklist 10.11.0.148获取黑名单IP:smembers 阅读全文
posted @ 2019-09-04 11:06 reblue520 阅读(1801) 评论(0) 推荐(0) 编辑
摘要: openresty开发系列37--nginx-lua-redis实现访问频率控制一)需求背景在高并发场景下为了防止某个访问ip访问的频率过高,有时候会需要控制用户的访问频次在openresty中,可以找到:set_by_lua,rewrite_by_lua,access_by_lua,content 阅读全文
posted @ 2019-09-04 10:54 reblue520 阅读(1234) 评论(0) 推荐(0) 编辑
摘要: openresty开发系列36--openresty执行流程之6日志模块处理阶段一)header_filter_by_lua 语法:header_filter_by_lua <lua-script-str>语境:http,server,location,location if阶段:output-he 阅读全文
posted @ 2019-09-02 14:46 reblue520 阅读(790) 评论(0) 推荐(0) 编辑
摘要: openresty开发系列35--openresty执行流程之5内容content阶段content 阶段 init阶段 重写赋值 重写rewrite accesscontent 阶段属于一个比较靠后的处理阶段,运行在先前介绍过的 rewrite 和 access 这两个阶段之后。当和 rewrit 阅读全文
posted @ 2019-09-02 14:44 reblue520 阅读(955) 评论(0) 推荐(1) 编辑
摘要: openresty开发系列34--openresty执行流程之4访问阶段访问阶段用途:访问权限限制 返回403nginx:allow 允许,deny 禁止allow ip;deny ip;涉及到的网关,有很多的业务 都是在access阶段处理的,有复杂的访问权限控制nginx:allow deny 阅读全文
posted @ 2019-09-02 14:42 reblue520 阅读(1181) 评论(0) 推荐(0) 编辑
摘要: openresty开发系列33--openresty执行流程之3重写rewrite和重定向重写rewrite阶段1)重定向2)内部,伪静态先介绍一下if,rewrite指令一)if指令语法:if (condition){...}默认值:无作用域:server,location对给定的条件condit 阅读全文
posted @ 2019-09-02 14:31 reblue520 阅读(3892) 评论(0) 推荐(0) 编辑
摘要: openresty开发系列33--openresty执行流程之2重写赋值阶段一)重写赋值阶段1)set_by_lua 语法:set_by_lua $res <lua-script-str> [$arg1 $arg2 …]语境:server、server if、location、location if 阅读全文
posted @ 2019-09-02 14:28 reblue520 阅读(467) 评论(0) 推荐(0) 编辑
摘要: openresty开发系列32--openresty执行流程之初始化阶段一)初始化阶段1)init_by_lua init_by_lua_block init_by_lua_file语法:init_by_lua <lua-script-str>语境:http阶段:loading-config当ngi 阅读全文
posted @ 2019-09-02 14:25 reblue520 阅读(1692) 评论(0) 推荐(0) 编辑
摘要: openresty开发系列31--openresty执行流程我们先看个例子location /test { set $a 32; echo $a; set $a 56; echo $a;}echo nginx第三方模块,是用于做响应输出输出了 56Nginx 处理每一个用户请求时,都是按照若干个不同 阅读全文
posted @ 2019-09-02 14:22 reblue520 阅读(1077) 评论(0) 推荐(0) 编辑
摘要: openresty开发系列30--openresty中使用全局缓存Nginx全局内存 本地缓存使用过如Java的朋友可能知道如Ehcache等这种进程内本地缓存。Nginx是一个Master进程多个Worker进程的工作方式,因此我们可能需要在多个Worker进程中共享数据。使用ngx.shared 阅读全文
posted @ 2019-09-02 14:21 reblue520 阅读(2541) 评论(0) 推荐(0) 编辑
摘要: Last_SQL_Errno: 1197 Coordinator stopped because there were error(s) in the worker(s). The most recent failure being: Worker 0 failed executing transa 阅读全文
posted @ 2019-08-30 15:53 reblue520 阅读(2684) 评论(0) 推荐(0) 编辑
摘要: openresty开发系列29--openresty中发起http请求有些场景是需要nginx在进行请求转发用户浏览器请求url访问到nginx服务器,但此请求业务需要再次请求其他业务;如用户请求订单服务获取订单详情,可订单详情中需要返回商品信息,也就需要再请求商品服务获取商品信息;这样就需要ngi 阅读全文
posted @ 2019-08-30 14:34 reblue520 阅读(4325) 评论(0) 推荐(0) 编辑
摘要: 配置示例 lua脚本 阅读全文
posted @ 2019-08-30 14:34 reblue520 阅读(4632) 评论(0) 推荐(0) 编辑
摘要: openresty开发系列28--openresty中操作mysqlMysql客户端 应用中最常使用的就是数据库了,尤其mysql数据库,那openresty lua如何操作mysql呢? 默认安装OpenResty时已经自带了该模块。案例,mysql数据库的常用操作,编辑testmysql.lua 阅读全文
posted @ 2019-08-30 14:01 reblue520 阅读(1772) 评论(0) 推荐(0) 编辑
摘要: openresty开发系列27--openresty中封装redis操作在关于web+lua+openresty开发中,项目中会大量操作redis,重复创建连接-->数据操作-->关闭连接(或放到连接池)这个完整的链路调用完毕,甚至还要考虑不同的 return 情况做不同处理,就很快发现代码中有大量 阅读全文
posted @ 2019-08-30 13:53 reblue520 阅读(1615) 评论(2) 推荐(0) 编辑
摘要: openresty开发系列26--openresty中使用redis模块在一些高并发的场景中,我们常常会用到缓存技术,现在我们常用的分布式缓存redis是最知名的,操作redis,我们需要引入redis模块 require "resty.redis";我们现在做个可以操作redis进行赋值,读值的案 阅读全文
posted @ 2019-08-30 11:59 reblue520 阅读(4114) 评论(0) 推荐(0) 编辑
摘要: openresty开发系列25--openresty中使用json模块web开发过程中,经常用的数据结构为json,openresty中封装了json模块,我们看如何使用一)如何引入cjson模块,需要使用requirelocal json = require("cjson")json.encode 阅读全文
posted @ 2019-08-30 11:54 reblue520 阅读(4256) 评论(0) 推荐(0) 编辑
摘要: openresty开发系列24--openresty中lua的引入及使用openresty 引入 lua一)openresty中nginx引入lua方式 1)xxx_by_lua >字符串编写方式 2) xxx_by_lua_block >代码块方式 3) xxx_by_lua_file >直接引用 阅读全文
posted @ 2019-08-30 11:52 reblue520 阅读(6988) 评论(0) 推荐(0) 编辑
摘要: openresty开发系列23--lua面向对象面向对象编程(Object Oriented Programming,OOP)是一种非常流行的计算机编程架构。java,c++,.net等都支持面向对象面向对象特征1) 封装:指能够把一个实体的信息、功能、响应都装入一个单独的对象中的特性。2) 继承: 阅读全文
posted @ 2019-08-30 11:19 reblue520 阅读(590) 评论(0) 推荐(0) 编辑
摘要: openresty开发系列22--lua的元表举个例子,在 Lua table 中我们可以访问对应的key来得到value值,但是却无法对两个 table 进行操作。那如何计算两个table的相加操作a+b?local t1 = {1,2,3}local t2 = {4,5,6}local t3 = 阅读全文
posted @ 2019-08-30 11:15 reblue520 阅读(340) 评论(0) 推荐(0) 编辑
摘要: openresty开发系列21--lua的模块从lua5.1开始,Lua 加入了标准的模块管理机制,Lua 的模块是由变量、函数等已知元素组成的 table,因此创建一个模块很简单,就是创建一个 table,然后把需要导出的常量、函数放入其中,最后返回这个 table 就行。一)模块定义模块的文件名 阅读全文
posted @ 2019-08-30 10:58 reblue520 阅读(728) 评论(0) 推荐(0) 编辑
摘要: openresty开发系列20--lua的时间操作在 Lua 中,函数 time、date 和 difftime 提供了所有的日期和时间功能。在 OpenResty 的世界里,不推荐使用这里的标准时间函数,因为这些函数通常会引发不止一个昂贵的系统调用,同时无法为 LuaJIT JIT 编译,对性能造 阅读全文
posted @ 2019-08-30 10:57 reblue520 阅读(1300) 评论(0) 推荐(0) 编辑
摘要: openresty开发系列19--lua的table操作Lua中table内部实际采用哈希表和数组分别保存键值对、普通值;下标从1开始不推荐混合使用这两种赋值方式。local color={first="red", "blue", third="green", "yellow"}print(colo 阅读全文
posted @ 2019-08-30 10:18 reblue520 阅读(1465) 评论(0) 推荐(0) 编辑
摘要: openresty开发系列18--lua的字符串string操作string的相关操作1)string.upper(s)接收一个字符串 s,返回一个把所有小写字母变成大写字母的字符串。print(string.upper("Hello Lua")) -->output HELLO LUA2)stri 阅读全文
posted @ 2019-08-30 10:14 reblue520 阅读(2157) 评论(1) 推荐(0) 编辑
摘要: 与其他脚本语言不同的是,Lua并不使用POSIX规范的正则表达式[4](也写作regexp)来进行模式匹配。主要的原因出于程序大小方面的考虑:实现一个典型的符合POSIX标准的regexp大概需要4000行代码,这比整个Lua标准库加在一起都大。权衡之下,Lua中的模式匹配的实现只用了500行代码, 阅读全文
posted @ 2019-08-29 15:11 reblue520 阅读(671) 评论(0) 推荐(0) 编辑
上一页 1 ··· 4 5 6 7 8 9 10 11 12 ··· 34 下一页