Example #1
0
 function getCache()
 {
     if ($this->hasCache()) {
         return Project::getCacheManager()->get($this->_cache_module_id);
     } else {
         return null;
     }
 }
Example #2
0
 public function initialize(IConfigParameter $configuration)
 {
     if (!extension_loaded('apc')) {
         throw new SoftwareSupportException("APC extension not loaded");
     }
     if ($configuration->get('id') === null) {
         throw new CacheException("Cache module must have id");
     }
     // Need checking for necessary cache id
     Project::getCacheManager()->set($configuration->get('id'), $this);
     parent::initialize($configuration);
 }
Example #3
0
 public function initialize(IConfigParameter $configuration)
 {
     parent::initialize($configuration);
     $engine = new Cache_Lite();
     if (!$configuration->get('directory')) {
         throw new CacheException('FileCache: cache directory not specified');
     }
     $engine->_cacheDir = Project::NS()->path($configuration->get('directory'));
     if ($configuration->get('file_name')) {
         $engine->_fileName = $configuration->get('file_name');
     } else {
         $engine->_fileName = "file.cache";
     }
     $this->_engine = $engine;
     Project::getCacheManager()->set($configuration->get('id'), $this);
 }
Example #4
0
 public function initialize(IConfigParameter $configuration)
 {
     if (!extension_loaded('sqlite_open')) {
         throw new SoftwareSupportException('SQL extension not loaded');
     }
     if ($this->_file === null) {
         // TODO:: need getting directory to storing file and check permissions
         $this->_file = 'sqlite.cache';
     }
     $error = '';
     if (($this->_db = new SQLiteDatabase($this->_file, 0666, $error)) === false) {
         throw new CacheException('Error connection to sqlite server', $error);
     }
     if (@$this->_db->query('DELETE FROM ' . $this->_cache_table . ' WHERE expire<>0 AND expire<' . time()) === false) {
         if ($this->_db->query('CREATE TABLE ' . $this->_cache_table . ' (key CHAR(128) PRIMARY KEY, value BLOB, expire INT)') === false) {
             throw new CacheException('Errir creation sqlite table', sqlite_error_string(sqlite_last_error()));
         }
     }
     $this->_initialized = true;
     parent::initialize($configuration);
     Project::getCacheManager()->set($configuration->get('id'), $this);
 }