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

default to cache_key #9

Open
gottfrois opened this issue Nov 3, 2015 · 0 comments
Open

default to cache_key #9

gottfrois opened this issue Nov 3, 2015 · 0 comments

Comments

@gottfrois
Copy link

Any reason why you are not using cache_key instance method by default?

post = Post.find(params[:id])
cache(key: post.cache_key, etag: post.updated_at, expires_in: 2.hours) do
  post # post.extend(PostRepresenter) etc, any code that renders response
end

post.cache_key could also be used to generate etag since the key already includes the updated_at.

This would allow a nicer API:

post = Post.find(params[:id])
cache(post, expires_in: 2.hours) do
  post # post.extend(PostRepresenter) etc, any code that renders response
end
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

1 participant