Russian Doll Caching
Is it possible or in the road map?
class Song
belongs_to :artist
end
class Artist
has_many :songs
end
class SongRepresenter
property :artist, extend: ArtistRepresenter
end
class ArtistRepresenter
property :name
end
Let's imagine I update the song but not the artist. It would be nice to get the serialized artist data from cache instead of going through the entire serialization process again.
What do you think?
Everything's possible, and everything's on the road map. :grimacing:
Looks good to me, but I need to think about what would go into Representable and what is actually the data layers' responsibility.
Not top prio right now, though... we can discuss it here.
what i'm afraid is that, correct me if i'm wrong, representable generate the json at once, taking all properties and serialize it into json. If we want to have russian doll caching, I would guess we want to store json fragments into cache and fetch it every time we need that data.
But maybe we can leverage the from_json strategy to retreive the cached json and merge it with the rest.
Yes, and no! :grin: Representable as per today calls to_hash on nested representers to serialise them. This step could be saved by leveraging the cached hash. We can also think about changing the way JSON gets rendered and allow concatenating a string instead of the intermediate hash representation.
I'm a bit confused by the from_json? Are we talking about rendering? Or parsing?
Sounds like a good plan. Talking about rendering, sorry for the confusion :)