Skip to content
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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

conroywhitney
Copy link

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 calls Rails.cache.fetch which, if dalli 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 the hosting branch.

cache -- include activesupport gem; basic tag with spec

cache -- get key from options hash

cache -- swap order of options/tokens per send_mail example

cache -- accept array of key parts to join with separator

cache -- renamed to Cacher; creating composite key from given string

cache -- remove single quote from user submitted key

cache -- error => undefined method `context' for #<Liquid::Document

cache -- remove error_mode = :strict per tag/for example

cache -- remove whitespace around key

cache -- use Rails.cache in production

cache -- check for dalli gem to use Rails.cache

cache -- check for rails gem to use Rails.cache

cache -- remove both single and double quotes

cache -- inherit Solid::Block -- use variables in cache key

cache -- removed unused argument parsing method

cache -- don't add blank user parts

cache -- renamed variable cache_mechanism

cache -- remove wrapping slashes

cache -- change key root namespace prefix to 'locomotive'

cache -- remove logging unless in development

cache -- convert specs from .should to expect().to syntax

cache -- set Gemfile back to original so no spurious merge items
@conroywhitney conroywhitney changed the title Cache Liquid block wrapping Rails.cache.fetch {% cache %} block wrapping Rails.cache.fetch (master) Dec 17, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant