Skip to content

Instantly share code, notes, and snippets.

Avatar

Jesse Gardner plasticmind

View GitHub Profile
@markjaquith
markjaquith / gist:2653957
Created May 10, 2012
WordPress Fragment Caching convenience wrapper
View gist:2653957
<?php
/*
Usage:
$frag = new CWS_Fragment_Cache( 'unique-key', 3600 ); // Second param is TTL
if ( !$frag->output() ) { // NOTE, testing for a return of false
functions_that_do_stuff_live();
these_should_echo();
// IMPORTANT
$frag->store();
// YOU CANNOT FORGET THIS. If you do, the site will break.