OpenResty LuaJIT 进阶和高级用法

1. 数据结构table

LuaJIT 中只有 table 这一个数据结构,并没有区分开数组、哈希、集合等概念,而是揉在了一起

1.1 lua标准table 库函数

1.1.1 table.getn 获取元素个数

对于序列,用table.getn 或者一元操作符 # ,就可以正确返回元素的个数:

local t = {
    1, 2, 3 }
print(table.getn(t)
  • 2
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论
要确认 OpenResty 是否安装了 LuaJIT,可以通过以下两种方法进行: 1. 查看 OpenResty 版本信息 打开终端,输入 `openresty -v` 命令,查看 OpenResty 的版本信息: ``` $ openresty -v nginx version: openresty/1.19.9.1 built by gcc 7.5.0 (Ubuntu 7.5.0-3ubuntu1~18.04) built with OpenSSL 1.1.1g 21 Apr 2020 TLS SNI support enabled configure arguments: --prefix=/usr/local/openresty/nginx --with-http_ssl_module --with-http_v2_module --with-openssl=/usr/local/src/openssl-1.1.1g --with-pcre=/usr/local/src/pcre-8.44 --with-pcre-jit --with-cc-opt='-O2 -fdebug-prefix-map=/data/builder/debuild/nginx-1.19.9/debian/debuild-base/nginx-1.19.9=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2' --with-ld-opt='-Wl,-z,relro -Wl,-z,now -Wl,--as-needed -pie' ``` 如果在命令输出中看到 `built with LuaJIT` 字样,则表示 OpenResty 是使用 LuaJIT 编译的,已经安装了 LuaJIT。 2. 查看 OpenResty Lua 模块 打开终端,输入 `openresty -V` 命令,查看 OpenResty 编译时开启的 Lua 模块: ``` $ openresty -V openresty version: openresty/1.19.9.1 built by gcc 7.5.0 (Ubuntu 7.5.0-3ubuntu1~18.04) built with OpenSSL 1.1.1g 21 Apr 2020 TLS SNI support enabled configure arguments: --prefix=/usr/local/openresty/nginx --with-http_ssl_module --with-http_v2_module --with-openssl=/usr/local/src/openssl-1.1.1g --with-pcre=/usr/local/src/pcre-8.44 --with-pcre-jit --with-cc-opt='-O2 -fdebug-prefix-map=/data/builder/debuild/nginx-1.19.9/debian/debuild-base/nginx-1.19.9=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2' --with-ld-opt='-Wl,-z,relro -Wl,-z,now -Wl,--as-needed -pie' ``` 如果在命令输出中看到 `--with-luajit` 或者 `--with-lua` 字样,则表示 OpenResty 安装了 LuaJIT。其中,`--with-luajit` 表示使用 LuaJIT 编译,`--with-lua` 表示使用官方 Lua 编译。如果两个选项都没有出现,则表示 OpenResty 没有安装 LuaJIT

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

lovelife110

你的鼓励是我创作的动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值