Skip to content

cache not working #1210

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
passalini opened this issue Sep 28, 2015 · 5 comments
Closed

cache not working #1210

passalini opened this issue Sep 28, 2015 · 5 comments

Comments

@passalini
Copy link

I google and try a lot, but I just can't see/do the AMS's cache work.
Right now I'm in development env using 0.10.0.rc3

ps: I can use Rails.cache normally

# enviroments/development.rb
  config.action_controller.perform_caching = true
  config.cache_store = :dalli_store, 'localhost:11211'
# lesson_serializer.rb
class LessonSerializer < ActiveModel::Serializer
  cache key: 'lesson-serialized'
  delegate :cache_key, to: :object

  attributes ....
end

Any help will be very welcome!!

@passalini
Copy link
Author

Update

I can see the cache working on ubuntu 15.04 but not in my other machine, OS X Yosemite 10.10.5,
both using rbenv, ruby 2.1.5 and rails 4.2.1.

I will close the issue, but when I figure out why it does not work in osx, I will do an updade here!
:)

@beauby
Copy link
Contributor

beauby commented Sep 29, 2015

@passalini Great, please keep us posted if you find the reason so that we can include it in an FAQ.

@passalini
Copy link
Author

@beauby today the code just work, memory's garbage perhaps? I don't konw yet, but if I figure out I will come back.

@sevab
Copy link

sevab commented Jan 3, 2016

I have a similar issue, I was on 0.10.0.rc3 (specifically https://github.com/rails-api/active_model_serializers/tree/efe5128a2e6b8578d81bc7a807ace427c0b4d847) and updated to today's master (specifically https://github.com/rails-api/active_model_serializers/tree/df594c630db5b11c1c0b7c9f053fa4275a2ee035) and suddenly caching via cache key: some_key inside the serializer just stopped working, or at least no cache reads/writes are logged to the console. Caching via Rails.cache.fetch in the controller still works though.

I tried to find the last commit where caching still worked and 21fe3ab is the last one. Starting from 170db3b the caching stopped working.

I'm using OS X El Capitan, ruby '2.3.0' and rails 4.2.1.

config.action_controller.perform_caching = true is enabled

@bf4
Copy link
Member

bf4 commented Jan 4, 2016

@sevab There's an open issue for this at #923 (comment) if you'd like to repost there.

Also, I'm having a heckavu time demonstrating caching as improving performance, and when that went away. See #1393 and I think #1352 might help. So, I'd appreciate any code you could share demonstrating the change in behavior and performance. Maybe join the slack? https://github.com/rails-api/active_model_serializers#getting-help

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

No branches or pull requests

4 participants