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
Add support for expires_in:
when using render
with collection:
#51579
base: main
Are you sure you want to change the base?
Conversation
actionview/lib/action_view/renderer/partial_renderer/collection_caching.rb
Show resolved
Hide resolved
- Pass `expires_in:` to `write_multi` so the cache key is written with the expiration. - Added test. - Added documentation.
eddd149
to
be616f6
Compare
Thanks for the PR @jclusso ! |
I don't understand what that means. You'd have to give me an example. |
Much like the cache-key can be specified using a block (i.e. for each item), it would be great to have the same flexibility for the expiration calculation. Since the original thread came from the idea of improving cache efficiency, using a logic "one expiry for all entries" does leave room open for improving the efficiency. For example, a model could implement a method, say
Could also think about supporting a symbol, but don't wanna overcomplicate things
With this addition, it is similar to the cache key, which allows a simple switch ( |
I see, I think I'll leave that to someone else to open a PR for. That need seems very niche and will increase the complexity of this change substantially. I'm also not confident maintainers would support that, whereas I'd be surprised if they wouldn't be receptive to this as it stands. |
Alright, sounds good to me |
I think that As @jclusso said, it would be better for another PR, because it can affect multiple other parts. |
Motivation / Background
When using the following code you'd expect that you can pass
expire_in
as you can with rendering individual partials.Detail
expires_in
towrite_multi
so the cache key is written with the expiration.Checklist
[Fix #issue-number]