public function testCache() { $a = array(); $f = function ($id, $data, $event = null) use(&$a) { if (!isset($event)) { $event = $data; } $a[] = $event; }; self::$db->on('loaded', $f); $cache = new Cache(self::$db); self::$db->save('cached', array('foo' => 'bar')); $a[] = $cache->load('cached'); $a[] = $cache->load('cached'); $ex = array('loaded', array('foo' => 'bar'), array('foo' => 'bar')); $this->assertEquals($ex, $a); }
/** * Save index */ public function store() { $this->sort(); // keep map sorted by key $this->db->save('_' . $this->name . '_index', array('name' => $this->name, 'type' => 'index', 'map' => $this->map, 'inverse' => $this->inverse)); }