-
Notifications
You must be signed in to change notification settings - Fork 2k
ngx.shared.DICT.incr optional expire argument #942
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Let me know if its good and I'll do stream & resty-core. |
src/ngx_http_lua_shdict.c
Outdated
if (n != 3 && n != 4) { | ||
return luaL_error(L, "expecting 3 or 4 arguments, but only seen %d", n); | ||
if (n < 3) { | ||
return luaL_error(L, "expecting at least 3 arguments, but only seen %d", n); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line exceeds 80 columns. Please use the ngx-releng tool to check such things.
done |
lua_shared_dict dogs 1m; | ||
--- config | ||
location = /test { | ||
content_by_lua ' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Newly added test cases should use the *_by_lua_block form instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll do a future PR changing all the shdict tests to _block, not just these ones. It's an easy regex.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@splitice I prefer keeping the old tests intact. Just the newly added ones should use *_by_lua_block
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Feel free to make adjustments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@splitice You want me to make adjustments in your branch? Sorry, no, I can't, obviously :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@splitice We can only help with the review process since we have many other items with much higher priorities. Thanks for your understanding.
sd->expires = (uint64_t) tp->sec * 1000 + tp->msec | ||
+ (uint64_t) (exptime * 1000); | ||
|
||
} else if (exptime == 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better make exptime < 0
turn into exptime == 0
as well. So better replace this else if
with else
directly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Those are different code paths. Not adjusting the exptime (<0 aka -1 the default for null) vs setting it to not expire (0)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@splitice Okay, got it.
if (init < 0) { | ||
return luaL_error(L, "bad \"init\" argument"); | ||
} | ||
has_init = 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style: need a blank line after the }
line.
@splitice Have you created the corresponding PR for lua-resty-core's FFI-based API? |
@splitice Thank you for your contribution! Will you please look at my comments and questions above? Thanks! |
I think we also need updates in the documentation :) |
Hmm, seems like we should permanently switch over to the FFI-based implementations to lua-resty-core. I'm already sick of maintaining two parallel implementations of the same Lua API :) I bet you can feel the pain as well :) @doujiang24 @membphis @moonbingbing @thibaultcha @yangshuxin Shall we? ;) |
I think so too. Having to provide two implementations for each new feature can also discourage a lot of contributors (I think it has been the case a few times already) and we may be missing a few opportunities to add relevant features. However, this does raise a few concerns on the long term:
|
@thibaultcha To answer your concerns:
|
Another upside of this is that the ngx_lua core will also be smaller :) The downside is that we now require lua-resty-core and lua-resty-lrucache for ngx_lua. The latter is not a problem if the user uses OpenResty, of course. |
Is this an existing feature or a suggestion to solve those concerns? If so, I was about to suggest the same behavior as well (and disable it by default when not using LuaJIT). |
@thibaultcha It's a suggestion. I think I'd also drop the support for the standard Lua 5.1 interpreter in ngx_lua and openresty. LuaJIT is already diverged a lot from it and it's becoming a big burden for us due to the lack of FFI in the standard Lua 5.1 interpreter, for example. In addition, the user can selectively choose which lua_use_resty_core regex shdict; # only load the modules resty.core.regex and resty.core.shdict By default, it could be |
@thibaultcha Alas. We should have created a separate ticket for it. |
@thibaultcha Let's move our discussion over to #949 to avoid off-topic :) Thanks! |
Like this feature there has been a PR for lua-resty-core for 2 years. It needs a rebase & for the argument order to be re-ordered. There is also a PR for the stream module that needs upgrading for the argument order same as this one. |
@splitice For your pull requests to be merged, they have to pass the review process. Thank you for your understanding :) |
@splitice So please do not blame us for not merging your old PRs for years. They just never passed the review process like the lack of test cases and etc in your old PRs. |
@splitice I do appreciate your contributions a lot and I also hope that you can respect our review process and PR merging policies. Thank you! |
@splitice We're already trying our best to collaborate and cooperate with our contributors. I hope that you can see that from our active review feedback and etc. |
@splitice Consider that these are all volunteering work. |
And I too am volunteering my time to merge upstream suitable features developed on projects I am involved with. We are all volunteers here. It's fine to do a review but the constant back and forth over small style fixes that would have taken you less time to fix than to comment on is just wasteful. Due to the time wasted by this not even being looked at that I am now investing time in rebasing & re-ordering the parameters (the new order is only required due to the time-lag, and IMHO less consistent ordering considering set/add). At the end of the day its your project and you can accept changes however you please. But just take a look at the ancient PRs, plenty of good features abandoned there. Plenty that even look complete. As this was submitted 2-3 years ago and never processed, none of our other patches have been even considered for pushing upstream. To give you an idea of the PRs that you have missed out on from this project alone:
Now back to this PR, you can quite easily make any minor style changes you so desire. You should know how, merge it into a feature branch, add a commit and then merge to master. Done and dusted. Going back and forth with minor style changes over years is only wasting both of our times. I'm sure it takes you longer to write your comment than to add a newline. Now I could go change all the newly added tests, I could also upgrade the existing with the same regex as a separate PR but realistically it's a waste of time as it looks like this code will be replaced with resty-core soon so not worth the time investment. It will either require a re-base, or removed depending on how the code ends up structured. Either way. Continuing to consider this a fork is fine for us at this point as the path of least resistance. |
This function does not exist anymore since we removed the CFunction implementation (as originally discussed in this PR!) in 947fa00. The FFI implementation of this API has support for the |
FYI init_ttl != expire for anyone using my fork (which I continue to maintain). init_ttl does what it name says while expire continues to bump the TTL (i.e for LRU pattern) |
@splitice Good to know (and important distinction), thanks for clarifying. |
Rebased #358
I'll do a future commit changing all the shdict tests to _block.
I hereby granted the copyright of the changes in this pull request
to the authors of this lua-nginx-module project.