Created
June 18, 2012 06:49
-
-
Save naiquevin/2947187 to your computer and use it in GitHub Desktop.
Kodemall Cache examples
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 | |
class DummyCacheBackend implements CacheBackend { | |
public function get($key) { | |
return array(); | |
} | |
public function set($key, $value) { | |
return; | |
} | |
public function delete($key) { | |
return; | |
} | |
} | |
// and then while bootstrapping tests.. | |
$cache = new Cache(new DummyCacheBackend()); | |
$registry->set('cache', $cache); |
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 | |
$cache = new Cache(new FileSystemCacheBackend()); | |
$registry->set('cache', $cache); |
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 | |
class TestCacheBackend implements CacheBackend { | |
protected $_cache = array(); | |
public function get($key) { | |
return isset($this->_cache[$key]) ? $this->_cache[$key] : array(); | |
} | |
public function set($key, $value) { | |
$this->_cache[$key] = $value; | |
} | |
public function delete($key) { | |
$this->_delete(array($key)); | |
} | |
public function is_cached($key) { | |
return isset($this->_cache[$key]); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment