Skip to content

feature: implemented shdict:ttl() and shdict:expire() APIs #140

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

Closed

Conversation

thibaultcha
Copy link
Member

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

Hi there,

This is a stab at:

No documentation for now, just a proposal. I thought about including this API in a ngx.shared module the user would have to import explicitly (since they don't have Lua_CFunction counterparts), but went the easy way for now.

Probably needs a bit more polishing, open to feedback here!

I would have opened a PR for shdict:get_info() as well but apparently have been beaten to it :)

@thibaultcha
Copy link
Member Author

As soon as I hear this API is a go, I'll provide documentation for it!

@agentzh
Copy link
Member

agentzh commented Sep 12, 2017

@thibaultcha Sorry for the delay on my side. I'll have a look later today. Thanks!

@agentzh
Copy link
Member

agentzh commented Sep 12, 2017

@thibaultcha What is the sister PR in lua-nginx-module?

@agentzh
Copy link
Member

agentzh commented Sep 12, 2017

@thibaultcha Never mind, just found the sister ngx_lua PR myself: openresty/lua-nginx-module#1150

@thibaultcha
Copy link
Member Author

Ok :) (It's in the list of referenced PRs in the GitHub UI, but since I referenced this PR in several other places, it became harder to distinguish. Sorry!)

@agentzh
Copy link
Member

agentzh commented Sep 12, 2017

@thibaultcha No worries :)

if key_len == 0 then
return nil, "empty key"
end
if key_len > 65535 then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better add a blank line between successive if statement blocks.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I certainly concur. It was only like so to be consistent with the above incr() method. Fixed.

if key_len == 0 then
return nil, "empty key"
end
if key_len > 65535 then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto.

@thibaultcha
Copy link
Member Author

It seems like a recent release of Luacheck might have (once again) broken its default settings and now reports errors for this codebase?

@agentzh
Copy link
Member

agentzh commented Sep 18, 2017

@thibaultcha Should we make the luacheck warnings non-fatal in travis testing?

@thibaultcha
Copy link
Member Author

thibaultcha commented Sep 19, 2017

@agentzh I am not sure if you are asking for my opinion, but if so, then I am a big fan of enforcing the linter check in CI. However, I only dedicate a single Travis job to linting, like here: https://travis-ci.org/thibaultcha/lua-resty-mlcache

This way, the CI test suites of a project is not impacted by potential linter failures (tests can still be successful even if the linter is complaining about something). It is a better separation of concerns in the CI imho.
Plus, if we want to, we can even declare the linter job to be an allowed_failure in Travis CI, so that the CI test suites can still be passing, but if one of us opens the Travis build, we can spot that the linter job failed. I have that setup for another project.

Happy to add those CI changes in #143 if you think they'd be valuable for lua-resty-core.

@agentzh
Copy link
Member

agentzh commented Sep 19, 2017

@thibaultcha I'm not sure if that would be a good use of your valuable time :) Maybe we can just stick with a particular version of luacheck to avoid such regressions?

@thibaultcha
Copy link
Member Author

thibaultcha commented Sep 19, 2017

Maybe we can just stick with a particular version of luacheck to avoid such regressions

Definitely a solution I have used in the past as well 👍 (I can try to keep an eye out for Luacheck releases to avoid lagging too far behind)

@agentzh
Copy link
Member

agentzh commented Sep 19, 2017

@thibaultcha Cool, thanks!

@thibaultcha
Copy link
Member Author

@agentzh I just added a commit to #143 which locks the Luacheck version to the latest available!

@thibaultcha
Copy link
Member Author

@dndx Thank you for your review!

@agentzh
Copy link
Member

agentzh commented Sep 20, 2017

@thibaultcha I'd propose the following patch to make the test better:

diff --git a/t/shared.t b/t/shared.t
index a4041b5..41d3bf8 100644
--- a/t/shared.t
+++ b/t/shared.t
@@ -129,10 +129,11 @@ failed to get ttl: not found
     }
 --- request
 GET /t
---- response_body_like
-0.2
+--- response_body_like chomp
+\A0.2
 sleep for 0.1s...
-0.0\d*
+-?0.0\d*
+\z
 --- no_error_log
 [error]
 [alert]

What do you think?

@agentzh
Copy link
Member

agentzh commented Sep 20, 2017

Merged. Thanks!

Will you create another PR to lua-nginx-module to document these new API functions? Thanks!

@thibaultcha
Copy link
Member Author

Great! Good idea for the test. Yes, I'll propose those docs as soon as I can. Do you have a prefered timeline? Some deadline? ASAP maybe?

@agentzh
Copy link
Member

agentzh commented Sep 20, 2017

@thibaultcha This week maybe? Next week is fine too :) Not that urgent. Thanks!

@thibaultcha
Copy link
Member Author

thibaultcha commented Sep 20, 2017

Sounds good! I'll try to allocate some time to it.

@agentzh
Copy link
Member

agentzh commented Sep 20, 2017

@thibaultcha Great! Thanks!

@thibaultcha thibaultcha deleted the feat/shm-ttl-expire branch January 12, 2018 02:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants