Ejemplo n.º 1
0
 /**
  * @test
  */
 public function shouldBeAbleToStoreJSONInJSONCache()
 {
     // given
     $this->createCapitalCollection();
     $capitals = new Capitals(5000, 6000);
     $this->assertEquals(4, count($capitals->getValues()));
     $this->triggerJSONFor('Capitals', array(5000, 6000));
     // when
     $cache = new LudoDBCache($capitals, array(5000, 6000));
     // then
     $val = $this->getDb()->getValue("select count(ID) from ludo_db_cache where class_name='Capitals'");
     $this->assertEquals(1, $val);
     $this->assertTrue($cache->hasData());
 }
Ejemplo n.º 2
0
 /**
  * Recreate ECO databaes tables from JSONConfig/eco.data.json
  * @throws Exception
  */
 public function generate()
 {
     if (!file_exists($this->getPgnFile())) {
         throw new Exception("Eco file " . $this->getPgnFile() . " does not exists");
     }
     if (!$this->exists()) {
         $this->createTable();
     }
     $this->deleteTableData()->yesImSure();
     LudoDBCache::clearByClass("Eco");
     $this->moveDataIntoJSONFile($this->getJSONData());
     $this->insertDefaultData();
 }
Ejemplo n.º 3
0
 /**
  * @test
  */
 public function shouldGetNewCacheAfterRecordHasBeenUpdated()
 {
     // given
     $capital = new Capital(2);
     $this->triggerJSONFor('Capital', 2);
     $capital->setName('Stavanger');
     $capital->commit();
     // when
     $this->triggerJSONFor('Capital', 2);
     $json = new LudoDBCache($capital, array(2));
     $values = $json->getCache();
     // then
     $this->assertEquals('Stavanger', $values['name']);
 }
Ejemplo n.º 4
0
 public function clearCache()
 {
     LudoDBCache::clearByClass('Capitals');
     parent::clearCache();
 }
Ejemplo n.º 5
0
 /**
  * Executes drop or deleteTableData
  * @example
  * $p = new Person();
  * $p->drop()->yesImSure();
  */
 public function yesImSure()
 {
     if (isset($this->riskyQuery)) {
         $this->db->query($this->riskyQuery);
         if ($this->shouldCache("read")) {
             LudoDBCache::clearByClass(get_class($this));
             $json = new LudoDBCache();
             $json->deleteTableData()->yesImSure();
         }
         $this->riskyQuery = null;
     }
 }
Ejemplo n.º 6
0
 protected function clearCache()
 {
     LudoDBCache::clearByClass("Folders");
 }
Ejemplo n.º 7
0
 /**
  * Clear database cache for this instance.
  */
 protected function clearCache()
 {
     if ($this->shouldCache("read") && !empty($this->arguments)) {
         LudoDBCache::clearBy(get_class($this) . "_" . implode("_", $this->arguments));
     }
 }