nginx本地缓存
nginx本地缓存需要在nginx.conf文件里面开启本地缓存
lua_shared_dict,用它来设置缓存变量和大小
比如:
lua_shared_dict item_cache 150m;
这段代码表示lua_shared_dict允许开启本地缓存,item_cache 为缓存变量名,150m为本地缓存的大小。
定义好本地缓存后,可以通过ngx.shared来拿到本地缓存变量。具体代码:
local item_cache = ngx.shared.item_cache
接着通过get方法取,再通过set方法存。
item_cache:get(key)
item_cache:set(key)

浙公网安备 33010602011771号