trailblazer / trailblazer-cells

Trailblazer's file structure for Cells.
Other
26 stars 10 forks source link

Use cell's name instead of `controller_path` in cache key generation #15

Open yogeshjain999 opened 3 years ago

yogeshjain999 commented 3 years ago

Fixes #13

Note that this change doesn't remove Cell or ::Cell from cell's name, as it is being done in controller_path. I think controller_path is independent of cache key generation, though this is open for discussion.

# Old behaviour

class Post::Cell::Show < Cell::ViewModel
  cache :show # cache key => "post/view/show/"
end
# New behaviour

class Post::Cell::Show < Cell::ViewModel
  cache :show # cache key => "post/cell/show/show/"
end
apotonick commented 3 years ago

Cool, I think this solves the TRB-specific problem better than in the cells gem. What are we doing with the versioning, though? At least a minor bump as it's an API change, well, not really, but people who're computing cache keys manually could get in trouble.

yogeshjain999 commented 3 years ago

Hmm I didn't get the part "computing cache keys manually could get in trouble". Do you mean they override state_cache_key ? Also, agree about this not being an API change. I think this should be a patch release. It would only involve additional cache hits for new keys.