Exemple #1
0
 /**
  * test that clear() doesn't wipe files not in the current engine's prefix.
  *
  * @return void
  */
 public function testClearWithPrefixes()
 {
     $FileOne = new FileEngine();
     $FileOne->init(array('prefix' => 'prefix_one_', 'duration' => DAY));
     $FileTwo = new FileEngine();
     $FileTwo->init(array('prefix' => 'prefix_two_', 'duration' => DAY));
     $data1 = $data2 = $expected = 'content to cache';
     $FileOne->write('prefix_one_key_one', $data1, DAY);
     $FileTwo->write('prefix_two_key_two', $data2, DAY);
     $this->assertEquals($FileOne->read('prefix_one_key_one'), $expected);
     $this->assertEquals($FileTwo->read('prefix_two_key_two'), $expected);
     $FileOne->clear(false);
     $this->assertEquals($FileTwo->read('prefix_two_key_two'), $expected, 'secondary config was cleared by accident.');
     $FileTwo->clear(false);
 }
 /**
  * init method
  *
  * Note the serialize param refers to the underlying cache engine. MiCache is always
  * storing serialized strings
  *
  * @param array $settings array()
  * @return void
  * @access public
  */
 public function init($settings = array())
 {
     parent::init(array_merge(array('engine' => 'MiFile', 'path' => CACHE . 'data' . DS, 'prefix' => '', 'lock' => false, 'serialize' => false, 'isWindows' => false), $settings));
     if (!isset($this->_File)) {
         if (!class_exists('File')) {
             require LIBS . 'file.php';
         }
         $this->_File = new File($this->settings['path'] . DS . 'cake');
     }
     if (DIRECTORY_SEPARATOR === '\\') {
         $this->settings['isWindows'] = true;
     }
     $this->settings['path'] = $this->_File->Folder->cd($this->settings['path']);
     if (empty($this->settings['path'])) {
         return false;
     }
     return $this->__active();
 }
Exemple #3
0
 /**
  * Test that clear() also removes files with group tags.
  *
  * @return void
  */
 public function testClearWithNoKeys()
 {
     $engine = new FileEngine();
     $engine->init(array('prefix' => 'cake_test_', 'duration' => DAY, 'groups' => array('one', 'two')));
     $key = 'cake_test_test_key';
     $engine->clear(false);
     $this->assertFalse($engine->read($key), 'No errors should be found');
 }
Exemple #4
0
 /**
  * init method
  *
  * Note the serialize param refers to the underlying cache engine. MiCache is always
  * storing serialized strings
  *
  * @param array $settings array()
  * @return void
  * @access public
  */
 public function init($settings = array())
 {
     parent::init(array_merge(array('engine' => 'MiFile', 'path' => CACHE . 'data' . DS, 'prefix' => '', 'lock' => false, 'serialize' => false, 'isWindows' => false), $settings));
     $path = new SplFileInfo($this->settings['path'] . DS . 'cake');
     try {
         $this->_File = $path->openFile('c+');
     } catch (Exception $e) {
         trigger_error($e->getMessage(), E_USER_WARNING);
         return false;
     }
     App::uses('Folder', 'Utility');
     $this->_File->Folder = new Folder();
     /*				
     if (!isset($this->_File)) {
     	if (!class_exists('File')) {
     		App::uses('File', 'Utility');
     	}
     	$this->_File = new File($this->settings['path'] . DS . 'cake');
     }
     */
     if (DIRECTORY_SEPARATOR === '\\') {
         $this->settings['isWindows'] = true;
     }
     $this->settings['path'] = $this->_File->Folder->cd($this->settings['path']);
     if (empty($this->settings['path'])) {
         return false;
     }
     return true;
     return $this->__active();
 }