Skip to content

Latest commit

 

History

History
29 lines (16 loc) · 1.47 KB

ngxshareddictadd.md

File metadata and controls

29 lines (16 loc) · 1.47 KB

ngx.shared.DICT.add

语法: success, err, forcible = ngx.shared.DICT:add(key, value, exptime?, flags?)

环境: init_by_lua*, set_by_lua*, rewrite_by_lua*, access_by_lua*, content_by_lua*, header_filter_by_lua*, body_filter_by_lua*, log_by_lua*, ngx.timer.*

类似 set 方法,但仅当存储字典 ngx.shared.DICT不存在 该 key 时执行存储 key-value 对。

如果参数 key 在字典中已经存在 (且没有过期),success 返回值为 false,同时 err 返回 "exist" (已存在)。

这个功能最早出现在 v0.3.1rc22 版本中。

更多功能请参考 ngx.shared.DICT

English Source

syntax: success, err, forcible = ngx.shared.DICT:add(key, value, exptime?, flags?)

context: init_by_lua*, set_by_lua*, rewrite_by_lua*, access_by_lua*, content_by_lua*, header_filter_by_lua*, body_filter_by_lua*, log_by_lua*, ngx.timer.*

Just like the set method, but only stores the key-value pair into the dictionary ngx.shared.DICT if the key does not exist.

If the key argument already exists in the dictionary (and not expired for sure), the success return value will be false and the err return value will be "exists".

This feature was first introduced in the v0.3.1rc22 release.

See also ngx.shared.DICT.

返回目录