Description
Considering my PR #693
Cache Composition (http://robots.thoughtbot.com/fast-json-apis-in-rails-with-key-based-caches-and) is one of the work-arounds for the absence of fragmente cache on AMS.
As we know, a fragment cache implementation would be extremely efficient to improve API's that have some dynamic attributes that may vary on every request.
Assuming that PR #693 will be merged soon, this should be a new feature to the cache implementation, my proposal is to follow Rails conventions, adding two new options to cache
method: only
and except
.
Example:
class PostSerializer < ActiveModel::Serializer
cache key: 'post', expires_in: 3.hours, only: [:title]
attributes :title, :body
has_many :comments
url :post
end
In the example, only the title
attribute would be cached, everything else would be retrieved from the Post
object. Except
would work exactly the opposite.
Despite of being a simple new feature it isn't quite easy and small. So I'm not moving forward with this on PR #693
I'll try to work on this asap, but would like to hear some thoughts about it.
cc/ @kurko @steveklabnik @nwjsmith