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

Russian Doll Caching #168

Open
gottfrois opened this issue Nov 26, 2015 · 4 comments
Open

Russian Doll Caching #168

gottfrois opened this issue Nov 26, 2015 · 4 comments

Comments

@gottfrois
Copy link

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?

@apotonick
Copy link
Member

Everything's possible, and everything's on the road map. 😬

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.

@gottfrois
Copy link
Author

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.

@apotonick
Copy link
Member

Yes, and no! 😁 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?

@gottfrois
Copy link
Author

Sounds like a good plan. Talking about rendering, sorry for the confusion :)

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

2 participants