-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Rails cache versioning changes breaks AMS cache module #2287
Comments
Would you be up to writing a PR? |
I can't implement the versioned cache system but I will be happy to open a PR to solve this using the |
I'm so sorry that I haven't been more active lately on AMS. I'm just not
using it now. I've happy to help anyone interesting in maintaining it.
…On Wed, Sep 26, 2018 at 12:41 PM cintamani ***@***.***> wrote:
I can't implement the versioned cache system but I will be happy to open a
PR to solve this using the #cache_key_with_version method
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#2287 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAIuQsJ4l-b9YdS4N8ioBuW96MlxF4RRks5ue7xZgaJpZM4W6vEC>
.
|
cintamani
added a commit
to cintamani/active_model_serializers
that referenced
this issue
Oct 1, 2018
In order to keep compatibility between the AMS cache feature and with Rails > 5.1 cache versioning, we have to use the `cache_key_with_version`. **NOTE** - This is a quick fix to the issue, if there will be future plans a proper cache versioning with recyclable key needs to be implemented. More info: rails-api#2287
cintamani
changed the title
Rails cache versioning changes breaks AMS cache module
[WIP] - Rails cache versioning changes breaks AMS cache module
Oct 1, 2018
cintamani
changed the title
[WIP] - Rails cache versioning changes breaks AMS cache module
Rails cache versioning changes breaks AMS cache module
Oct 1, 2018
I am having issues with this. |
cintamani
added a commit
to cintamani/active_model_serializers
that referenced
this issue
Jan 29, 2019
In order to keep compatibility between the AMS cache feature and with Rails > 5.1 cache versioning, we have to use the `cache_key_with_version`. **NOTE** - This is a quick fix to the issue, if there will be future plans a proper cache versioning with recyclable key needs to be implemented. More info: rails-api#2287
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Expected behaviour vs actual behaviour
Expected
The cache is invalidated when a record is updated in Rails app running 5.1 or higher versions of the gem with the ActiveRecord.cache_versioning config set to
true
Actual
The cache is not invalidated and the old record details are returned.
Steps to reproduce
Given a new rails application:
rails new my-test-app
.Given an RSpec test suite setup.
Given a user model
rails g model User name:string
Given AMS 10.7
Run this test to see the error:
Environment
ActiveModelSerializers Version: 10.7
Output of
ruby -e "puts RUBY_DESCRIPTION"
:ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-darwin17]
OS Type & Version: High Sierra, 10.13.3
Integrated application and version: Rails 5.2.1
Additional helpful information
The source of the issue has been identified in the code here: https://github.com/rails-api/active_model_serializers/blob/0-10-stable/lib/active_model/serializer/concerns/caching.rb#L285
The issue is the module relying on the
#cache_key
method to return the version.An easy fix would involve changing the
#cache_key
to#cache_key_with_version
https://api.rubyonrails.org/classes/ActiveRecord/Integration.html#method-i-cache_key_with_versiona more long-term solution would be to implement cache versioning within AMS cache model.
The text was updated successfully, but these errors were encountered: