Example #1
0
 /**
  * Gets APC instance if exists, otherwise creates a new instance.
  *
  * @return APC cache instance.
  */
 public static function getInstance()
 {
     if (self::$instance === NULL) {
         self::$instance = new self();
     }
     return self::$instance;
 }
Example #2
0
 /**
  * singleton function to return
  * the instance of the class
  *
  * @return APCCache or NoCache
  */
 public static function singleton()
 {
     if (!Cache::$enabled) {
         return NoCache::singleton();
     }
     if (!self::$instance) {
         self::$instance = new APCCache();
     }
     return self::$instance;
 }
Example #3
0
 public static function init()
 {
     #-------------------------------------------------------------------------------
     if (self::$instance === NULL) {
         #-------------------------------------------------------------------------------
         try {
             #-------------------------------------------------------------------------------
             Debug("[system/classes/auto/CacheManager.class.php]: Start initializing cache system.");
             #-------------------------------------------------------------------------------
             if (Extension_Loaded(MemcachedCache::EXT_NAME) && File_Exists(SPrintF('%s/.memcached', SYSTEM_PATH))) {
                 #-------------------------------------------------------------------------------
                 Debug('[system/classes/auto/CacheManager.class.php]: Force load MemcachedCache');
                 #-------------------------------------------------------------------------------
                 self::$instance = MemcachedCache::getInstance();
                 #-------------------------------------------------------------------------------
             } else {
                 if (Extension_Loaded(APCCache::EXT_NAME)) {
                     #-------------------------------------------------------------------------------
                     Debug('[system/classes/auto/CacheManager.class.php]: Load APCCache');
                     #-------------------------------------------------------------------------------
                     self::$instance = APCCache::getInstance();
                     #-------------------------------------------------------------------------------
                 } else {
                     if (Extension_Loaded(MemcachedCache::EXT_NAME)) {
                         #-------------------------------------------------------------------------------
                         Debug('[system/classes/auto/CacheManager.class.php]: Load MemcachedCache');
                         #-------------------------------------------------------------------------------
                         self::$instance = MemcachedCache::getInstance();
                         #-------------------------------------------------------------------------------
                     } else {
                         #-------------------------------------------------------------------------------
                         throw new Exception("Any supported cache not installed in your sysytem.");
                     }
                 }
             }
             #-------------------------------------------------------------------------------
             Debug("Cache system has been initialized.");
             #-------------------------------------------------------------------------------
         } catch (Exception $e) {
             #-------------------------------------------------------------------------------
             Debug("Cache system has not been installed: " . $e->getTraceAsString());
             #-------------------------------------------------------------------------------
         }
         #-------------------------------------------------------------------------------
         #-------------------------------------------------------------------------------
     }
     #-------------------------------------------------------------------------------
     return self::$instance;
     #-------------------------------------------------------------------------------
 }