grape-rails-cache
grape-rails-cache copied to clipboard
default to cache_key
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