Ejemplo n.º 1
0
 /**
  * @return DCache 
  */
 public static function cache()
 {
     // change the cache based on the config
     if (!self::$_cache) {
         $type = 'dummy';
         $cfg = Get::cfg('cache', false);
         if (!empty($cfg['type'])) {
             $type = $cfg['type'];
         }
         switch ($type) {
             case "apc":
                 if (!extension_loaded('apc')) {
                     self::$_cache = new DApcCache();
                     self::$_cache->init();
                 } else {
                     Log::add('APC functionality was not available on the server.');
                     self::$_cache = new DDummyCache();
                     self::$_cache->init();
                 }
                 break;
             case "file":
                 Log::add('File functionality was not available on the server.');
                 self::$_cache = new DFileCache();
                 self::$_cache->init();
                 break;
             case "memcache":
                 if (class_exists('Memcache')) {
                     self::$_cache = new DMemcache();
                     self::$_cache->init();
                 } else {
                     Log::add('Memcache functionality was not available on the server.');
                     self::$_cache = new DDummyCache();
                     self::$_cache->init();
                 }
                 break;
             case "dummy":
             default:
                 self::$_cache = new DDummyCache();
                 self::$_cache->init();
         }
     }
     return self::$_cache;
 }
Ejemplo n.º 2
0
 /**
  * Initialize the caching mechanism
  */
 public function init()
 {
     parent::init();
 }