# nginx.conf http { # you do not need to configure the following line when you # use LuaRocks or opm. lua_package_path "/path/to/lua-resty-mlcache/lib ...
分类:
其他好文 时间:
2020-02-29 20:24:03
阅读次数:
57
迭代器与泛型 for 1 迭代器与 closure 「迭代器」是一种可以遍历一种集合中的所有元素的机制 在 lua 中通常将迭代器表示为函数 每调用一次函数,即返回集合中的「下一个」元素 每个迭代器都需要在每次成功调用之间保存一些状态 这样就知道它现在所在的位置以及如何步进到一下位置 一个 clos ...
分类:
其他好文 时间:
2020-02-29 19:03:04
阅读次数:
68
-- -- classic, object model. -- -- Copyright (c) 2014, rxi -- -- This module is free software; you can redistribute it and/or modify it under -- the t ...
分类:
其他好文 时间:
2020-02-29 17:32:46
阅读次数:
70
lua 注释 1. 单行注释 -- 功能等同于C++中的// 2. 多行注释 --[[ 注释的内容 ]] 功能等同于C++中的 /**/ 3. 多行注释 --[ [ 注释和内容 ] ], 也等同于C++中的/**/, 这个主要用于注释的内容里面有像arr[arr2[idx]] 这种文本, 如果使用- ...
分类:
其他好文 时间:
2020-02-29 11:37:49
阅读次数:
58
链接:https://www.jianshu.com/p/753b06ca07b0 --冒号:在定义时省略了self --点号:在定义时不省略self Class = {} Class.__index = Class function Class.new(x,y) local cls = {} se ...
分类:
其他好文 时间:
2020-02-26 01:39:32
阅读次数:
68
一、根据url中的参数来确定缓存的key set_by_lua_block $dataArg { local enc = ngx.req.get_uri_args()["enc"] local key = ngx.req.get_uri_args()["key"] local name = ngx. ...
分类:
其他好文 时间:
2020-02-25 09:30:28
阅读次数:
65
常用的分布式锁 一、.基于数据库实现分布式锁 1. 悲观锁 利用select … where … for update 排他锁 注意: 其他附加功能与实现一基本一致,这里需要注意的是“where name=lock ”,name字段必须要走索引,否则会锁表。有些情况下,比如表不大,mysql优化器会 ...
分类:
其他好文 时间:
2020-02-24 09:22:34
阅读次数:
116
深入函数第一篇 1. 函数是 第一类值 ,具有特定的 词法域 第一类值 1. 第一类值的意思是函数与 lua 中的其他类型如数字,字符串具有相同的权力 2. 函数可以存储到全局变量或局部变量变量,还可以存储到 table 中 3. 可作为实参传递给其他函数,也可以作为其他函数的返回值 词法域 1. ...
分类:
其他好文 时间:
2020-02-23 22:16:33
阅读次数:
66
1 local function keepTwoDecimalPlaces(decimal) 2 decimal = decimal * 100 3 if decimal % 1 >= 0.5 then 4 decimal=math.ceil(decimal) 5 else 6 decimal=ma ...
分类:
其他好文 时间:
2020-02-23 18:05:21
阅读次数:
88
function numberToString(szNum) 阿拉伯数字转中文大写 local szChMoney = "" local iLen = 0 local iNum = 0 local iAddZero = 0 local hzUnit = {"", "十", "百", "千", "万" ...
分类:
其他好文 时间:
2020-02-23 17:55:39
阅读次数:
150