Skip to content
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

Add :expires_in option support for RedisCacheStore increment/decrement method #33254


None yet
4 participants
Copy link

huacnlee commented Jun 29, 2018

Redis not support incry with expire option, so call expire.

This fix is keep same behavior with the :memcached store.

irb> Rails.cache.increment("my_counter", 1, expires_in: 100)
=> 99
# skip set expire when "my_counter" has ttl
irb> Rails.cache.increment("my_counter", 1, expires_in: 200)
=> 98

This comment has been minimized.

Copy link

rails-bot commented Jun 29, 2018

Thanks for the pull request, and welcome! The Rails team is excited to review your changes, and you should hear from @kamipo (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

This repository is being automatically checked for code quality issues using Code Climate. You can see results for this analysis in the PR status below. Newly introduced issues should be fixed before a Pull Request is considered ready to review.

Please see the contribution instructions for more information.

@huacnlee huacnlee force-pushed the huacnlee:add-expires-in-option-support-for-redis-cache-store-increment-method branch to 9d5b02e Jun 29, 2018

@rafaelfranca rafaelfranca merged commit 4883f73 into rails:master Jun 29, 2018

2 checks passed

codeclimate All good!
continuous-integration/travis-ci/pr The Travis CI build passed

@huacnlee huacnlee deleted the huacnlee:add-expires-in-option-support-for-redis-cache-store-increment-method branch Jun 29, 2018

kaspth added a commit that referenced this pull request Jul 1, 2018

Refactor #33254.
Firstly, increment and decrement shouldn't care about the particulars of
key expiry. They should only know that they have to pass that responsibility
on to somewhere else.

Secondly, it moves the key normalization back inside the instrumentation like
it was originally. I think that matches the original design intention or at
the very least it lets users catch haywire key truncation.

Thirdly, it moves the changelog entry to the top of the file, where new entries
go. I couldn't understand what the entry was saying so I tried to rewrite it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.