lua-nginx-module icon indicating copy to clipboard operation
lua-nginx-module copied to clipboard

Add ngx_http_lua_ffi_shdict_store_when for set_when and safe_set_when

Open hnakamur opened this issue 6 years ago • 1 comments

This pull request adds ngx_http_lua_ffi_shdict_store_when which is used to define set_when and safe_set_when methods in ngx.shared.DICT.

These methods are useful for avoiding race conditions between successive calls of get and set. You pass old_value as well as value to set_when, and it changes the value only when the value for the key is still the same as old_value. Adding this method is suggested in the comment by @doujiang24.

I hereby granted the copyright of the changes in this pull request to the authors of this lua-nginx-module project.

hnakamur avatar Aug 07 '19 15:08 hnakamur

Test with the following pull request branches passes at https://travis-ci.org/hnakamur/lua-nginx-module/builds/569371351

  • https://github.com/openresty/lua-resty-core/pull/268
  • https://github.com/openresty/stream-lua-nginx-module/pull/171

hnakamur avatar Aug 08 '19 21:08 hnakamur