Skip to content

Instantly share code, notes, and snippets.

@naiquevin
Created June 18, 2012 06:49
Show Gist options
  • Save naiquevin/2947187 to your computer and use it in GitHub Desktop.
Save naiquevin/2947187 to your computer and use it in GitHub Desktop.
Kodemall Cache examples
<?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);
<?php
$cache = new Cache(new FileSystemCacheBackend());
$registry->set('cache', $cache);
<?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