Memcache caching, #18

git-svn-id: svn+ssh://code.netmonsters.ru/svn/majestic/branches/evo@120 4cb57b5f-5bbd-dd11-951b-001d605cbbc5
This commit is contained in:
pzinovkin
2010-03-05 18:41:02 +00:00
parent 00259cfe93
commit 2d7f5391f8
6 changed files with 287 additions and 21 deletions

37
cache/Cacher.php vendored Normal file
View File

@ -0,0 +1,37 @@
<?php
/**
* @copyright NetMonsters <team@netmonsters.ru>
* @link http://netmonsters.ru
* @package Majestic
* @subpackage Cache
* @since 2010-03-04
* @version SVN: $Id$
* @filesource $URL$
*/
class Cacher
{
/**
* Initialized cachers
*
* @var array
*/
static protected $caches = array();
static public function get($cacher, $config = null)
{
if (!isset(self::$caches[$cacher])) {
if (!$config) {
$config = Config::get($cacher);
}
$cache = new $cacher($config);
if (!$cache instanceof Cache) {
throw new Exception('Cache driver "' . $cacher . '" must extends Cache');
}
self::$caches[$cacher] = $cache;
}
return self::$caches[$cacher];
}
}