Skip to content

Instantly share code, notes, and snippets.

@notomato
Created August 17, 2012 10:01
Show Gist options
  • Save notomato/3377621 to your computer and use it in GitHub Desktop.
Save notomato/3377621 to your computer and use it in GitHub Desktop.
Example filter on model find
<?php
Posts::applyFilter('find', function($self, $params, $chain) {
$key = // Make a cache key from $params['options']
if ($result = Cache::read('default', $key)) {
return $result;
}
$result = $chain->next($self, $params, $chain);
Cache::write('default', $key, $result);
return $result;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment