/** * @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()); }
/** * 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(); }
/** * @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']); }
public function clearCache() { LudoDBCache::clearByClass('Capitals'); parent::clearCache(); }
/** * 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; } }
protected function clearCache() { LudoDBCache::clearByClass("Folders"); }
/** * Clear database cache for this instance. */ protected function clearCache() { if ($this->shouldCache("read") && !empty($this->arguments)) { LudoDBCache::clearBy(get_class($this) . "_" . implode("_", $this->arguments)); } }