Exemple #1
0
 public function _testDataMongoCache()
 {
     $ready = $this->_prepareMongo();
     if (!$ready) {
         return false;
     }
     //remove existing
     $mongo = new Mongo();
     $database = $mongo->phalcon_test;
     $collection = $database->caches;
     $collection->remove();
     $frontCache = new Phalcon\Cache\Frontend\Data();
     $cache = new Phalcon\Cache\Backend\Mongo($frontCache, array('mongo' => $mongo, 'db' => 'phalcon_test', 'collection' => 'caches'));
     $data = array(1, 2, 3, 4, 5);
     $cache->save('test-data', $data);
     $cachedContent = $cache->get('test-data');
     $this->assertEquals($cachedContent, $data);
     $cache->save('test-data', "sure, nothing interesting");
     $cachedContent = $cache->get('test-data');
     $this->assertEquals($cachedContent, "sure, nothing interesting");
     //Exists
     $this->assertTrue($cache->exists('test-data'));
     $this->assertTrue($cache->delete('test-data'));
 }
Exemple #2
0
 public function testCacheMongoFlush()
 {
     // Mongo
     list($ready, $collection) = $this->_prepareMongo();
     if (!$ready) {
         return false;
     }
     $frontCache = new Phalcon\Cache\Frontend\Data(array('lifetime' => 10));
     $cache = new Phalcon\Cache\Backend\Mongo($frontCache, array('mongo' => $ready, 'db' => 'phalcon_test', 'collection' => 'caches'));
     $cache->save('data', "1");
     $cache->save('data2', "2");
     $this->assertTrue($cache->flush());
     $this->assertFalse($cache->exists('data'));
     $this->assertFalse($cache->exists('data2'));
 }
Exemple #3
0
 public function testCacheMongoFlush()
 {
     $frontCache = new Phalcon\Cache\Frontend\Data(array('lifetime' => 10));
     // Mongo
     $ready = $this->_prepareMongo();
     if (!$ready) {
         return false;
     }
     $mongo = new MongoClient();
     $database = $mongo->phalcon_test;
     $collection = $database->caches;
     $collection->remove();
     $frontCache = new Phalcon\Cache\Frontend\Data();
     $cache = new Phalcon\Cache\Backend\Mongo($frontCache, array('mongo' => $mongo, 'db' => 'phalcon_test', 'collection' => 'caches'));
     $cache->save('data', "1");
     $cache->save('data2', "2");
     $this->assertTrue($cache->flush());
     $this->assertFalse($cache->exists('data'));
     $this->assertFalse($cache->exists('data2'));
 }