求助 openresty利用lua脚本查询遇到的问题
lua代码:
ngx.header.content_type="application/json;charset=utf8"
local cjson = require("cjson")
local mysql = require("resty.mysql")
local uri_args = ngx.req.get_uri_args()
local id = uri_args["id"]
local db = mysql:new()
db:set_timeout(1000)
local props = {
host = "XXX",
port = 3306,
database = "XXX",
user = "XXX",
password = "XXX"
}
local res = db:connect(props)
local select_sql = "select url,pic from tb_content where status ='1' and category_id="..id.." order by sort_order"
res = db:query(select_sql)
db:close()
local redis = require("resty.redis")
local red = redis:new()
red:set_timeout(2000)
local ip ="XXX"
local port = 6379
red:connect(ip,port)
red:set("content_"..id,cjson.encode(res))
red:close()
ngx.say("{flag:true}")
错误信息:
2020/10/09 09:09:56 [error] 14400#14400: *972 lua entry thread aborted: runtime error: /usr/local/openresty/lualib/resty/mysql.lua:236: attempt to perform arithmetic on field 'packet_no' (a nil value)
stack traceback:
coroutine 0:
/usr/local/openresty/lualib/resty/mysql.lua: in function '_send_packet'
/usr/local/openresty/lualib/resty/mysql.lua:781: in function 'close'
/root/lua/update_content.lua:20: in main chunk, client: 117.9.201.34, server: localhost, request: "GET /update_content?id=2 HTTP/1.1", host: "106.13.186.100"
2020/10/09 09:09:56 [error] 14400#14400: *973 open() "/usr/local/openresty/nginx/html/favicon.ico" failed (2: No such file or directory), client: 117.9.201.34, server: localhost, request: "GET /favicon.ico HTTP/1.1", host: "106.13.186.100", referrer: "http://106.13.186.100/update_content?id=2"
求助 openresty利用lua脚本查询遇到的问题相关推荐
- 《饥荒》利用LUA脚本点亮全地图,没有黑夜
打开%SteamLibrary%\steamapps\common\dont_starve\data\scripts\mainfunctions.lua 在最后一行之前添加如下代码 function ...
- arcgispython脚本开发工具_06-05【求助】利用python脚本语言开发新的Arctoolbox工具
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼 下面是一段python代码,要如何才能在Arctoolbox中实现呢? #-*- encoding:UTF-8 -*- #!/usr/bin/env py ...
- openresty测试lua脚本配置示例
- 使用ZeroBrane Studio调试OpenResty Lua脚本
本文固定链接: http://blog.sunqiang.me/2017/08/07/使用zerobrane-studio调试openresty和nginx-lua脚本/ 转载请注明: sunny51 ...
- Spring Redis中使用Lua脚本实现高并发原子操作
1. 前言 在上一文中我对 Lua 语言的一些简单的语法及其在 Redis 中的操作进行了介绍,但是在 Java 开发中我们还需要进一步的学习才能使这种技术落地.今天就结合Spring Data Re ...
- Redis6入门学习(三)--Redis_Jedis、事务、LUA脚本
title: Redis6入门学习(三) 文章目录 title: Redis6入门学习(三) **Redis_Jedis_测试** **Jedis所需要的jar包** **连接Redis注意事项** ...
- redis之lua脚本: 原子性 调试 嵌入高级语言
实验环境: redis: 6.0.9 redis执行lua脚本时, 出错不会回滚(rollback) 我们知道, 使用lua脚本可以在执行一串redis命令时, 实现一定原子性(lua脚本中多条指令执 ...
- 黑猴子的家:LUA脚本(Redis 秒杀案例)
Code -> GigHub https://github.com/liufengji/redis_seckill.git 1.概念 http://www.lua.org/download.ht ...
- java redis 批量删除_在Spring中使用Redis Lua脚本批量删除缓存
背景 之前分享了一篇利用lua脚本批量删除redis的key的文章.现在项目中我打算使用spring的缓存,而Spring缓存以前我是用ehcache来做实现的.没发现什么问题..这次我换成redis ...
最新文章
- R语言使用ggplot2包使用geom_dotplot函数绘制分组点图(配置显示的分组)实战(dot plot)
- Python控制流:顺序结构、分支结构、循环结构+for、if ... else、while、if... elif...elif..else、if
- 人月神话阅读笔记03
- 王道计算机考研 数据结构 (串)
- 《深入理解java内存模型》学习整理1
- 内置函数——filter和map
- python min函数 索引_使用列表中的max()/ min()获取返回的max或min项的索引
- STemwin替换为MDK下的emwin
- Shell命令-文件及内容处理之grep(egrep)、join
- 几种web报表打印方案的比较
- Linux下MySQL的简单使用(一)
- anaconda下载过慢修改源配置
- python编程第一站-简单密码字典生成
- plsql导出表结构到excel_PLSQL怎样导出oracle表结构和数据
- 单片机仿真软件proteus8安装与使用
- java 实现 excel 去重_用java对大量Excel表处理(去重,生成新属性,统计数量)
- ZPL指令打印标签时出现白色窄条的坑
- TensorFlow中的通信机制——Rendezvous(一)本地传输
- 如何设计空白页面,体验更好!
- 『居善地』接口测试 — 11、接口自动化框架的设计与实现(三)