This repository has been archived by the owner on Apr 5, 2018. It is now read-only.
{% cache %} block wrapping Rails.cache.fetch (master) #10
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Thank you for all of your work on LocomotiveCMS!
This pull request is for a
{% cache %}
liquid block which functions like Rails fragment caching. Behind the scenes, it callsRails.cache.fetch
which, ifdalli
is configured correctly on the LocomotiveCMS Engine, will make a call to a memcache-like datastore. If it is not configured, it will simply evaluate the block.I created this to speed up a "View All" SEO pagination page which was looping through many content entries and rendering snippets which resulted in many sequential MongoDB calls. The trade-off to having a single call to render this whole block is needing to manually call
Rails.cache.clear
after a content change. I am sure there is a better way around this!I have a corresponding
cache-hosting
branch that I will submit a pull request into thehosting
branch.