Last active
December 11, 2015 16:39
-
-
Save tommoor/4629529 to your computer and use it in GitHub Desktop.
Wrapping cache methods in CI
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
protected function cached($key, $callback, $life) | |
{ | |
$this->load->driver('cache', array('adapter' => 'memcached')); | |
if (!$response = $this->cache->get($key)) { | |
$response = $callback($this); | |
if ($response) { | |
$this->cache->save($key, $response, $life); | |
} | |
} | |
return $response; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment