/** * @return Zend_Cache_Core */ static function getCacheService() { return _DevblocksCacheManager::getInstance(); }
public function __destruct() { // [JAS]: If newly registered this instance, add to cache if ($this->newRegisters) { $cache = _DevblocksCacheManager::getInstance(); $cache->save($this->classMap, self::CACHE_CLASS_MAP); } }
/** * @return _DevblocksCacheManager */ public static function getInstance() { if (null == self::$instance) { self::$instance = new _DevblocksCacheManager(); $options = array('key_prefix' => defined('DEVBLOCKS_CACHE_PREFIX') && DEVBLOCKS_CACHE_PREFIX ? DEVBLOCKS_CACHE_PREFIX : null); // Shared-memory cache if ((extension_loaded('memcache') || extension_loaded('memcached')) && defined('DEVBLOCKS_MEMCACHED_SERVERS') && DEVBLOCKS_MEMCACHED_SERVERS) { $pairs = DevblocksPlatform::parseCsvString(DEVBLOCKS_MEMCACHED_SERVERS); $servers = array(); if (is_array($pairs) && !empty($pairs)) { foreach ($pairs as $server) { list($host, $port) = explode(':', $server); if (empty($host) || empty($port)) { continue; } $servers[] = array('host' => $host, 'port' => $port); } } $options['servers'] = $servers; self::$_cacher = new _DevblocksCacheManagerMemcached($options); } // Disk-based cache (default) if (null == self::$_cacher) { $options['cache_dir'] = APP_TEMP_PATH; self::$_cacher = new _DevblocksCacheManagerDisk($options); } } return self::$instance; }
/** * @return _DevblocksCacheManager */ public static function getInstance() { if (null == self::$instance) { self::$instance = new _DevblocksCacheManager(); $frontendOptions = array('cache_id_prefix' => defined('DEVBLOCKS_CACHE_PREFIX') && DEVBLOCKS_CACHE_PREFIX ? DEVBLOCKS_CACHE_PREFIX : null, 'lifetime' => 21600, 'write_control' => false, 'automatic_serialization' => true); // Shared-memory cache if (extension_loaded('memcache') && defined('DEVBLOCKS_MEMCACHED_SERVERS') && DEVBLOCKS_MEMCACHED_SERVERS) { $pairs = DevblocksPlatform::parseCsvString(DEVBLOCKS_MEMCACHED_SERVERS); $servers = array(); if (is_array($pairs) && !empty($pairs)) { foreach ($pairs as $server) { list($host, $port) = explode(':', $server); if (empty($host) || empty($port)) { continue; } $servers[] = array('host' => $host, 'port' => $port, 'persistent' => true); } } $backendOptions = array('servers' => $servers); self::$_zend_cache = Zend_Cache::factory('Core', 'Memcached', $frontendOptions, $backendOptions); } // Disk-based cache (default) if (null == self::$_zend_cache) { $backendOptions = array('cache_dir' => APP_TEMP_PATH); self::$_zend_cache = Zend_Cache::factory('Core', 'File', $frontendOptions, $backendOptions); } } return self::$instance; }