delete() public method

Delete a key from the database.
public delete ( string $key )
$key string
コード例 #1
0
ファイル: FlintstoneTest.php プロジェクト: fire015/flintstone
 protected function runOperationsTests($config)
 {
     $db = new Flintstone('test', $config);
     $arr = array('foo' => "new\nline");
     $this->assertFalse($db->get('foo'));
     $db->set('foo', 1);
     $db->set('name', 'john');
     $db->set('arr', $arr);
     $this->assertEquals(1, $db->get('foo'));
     $this->assertEquals('john', $db->get('name'));
     $this->assertEquals($arr, $db->get('arr'));
     $db->set('foo', 2);
     $this->assertEquals(2, $db->get('foo'));
     $this->assertEquals('john', $db->get('name'));
     $this->assertEquals($arr, $db->get('arr'));
     $db->delete('name');
     $this->assertFalse($db->get('name'));
     $this->assertEquals($arr, $db->get('arr'));
     $keys = $db->getKeys();
     $this->assertEquals(2, count($keys));
     $this->assertEquals('foo', $keys[0]);
     $this->assertEquals('arr', $keys[1]);
     $data = $db->getAll();
     $this->assertEquals(2, count($data));
     $this->assertEquals(2, $data['foo']);
     $this->assertEquals($arr, $data['arr']);
     $db->flush();
     $this->assertFalse($db->get('foo'));
     $this->assertFalse($db->get('arr'));
     $this->assertEquals(0, count($db->getKeys()));
     $this->assertEquals(0, count($db->getAll()));
     unlink($db->getDatabase()->getPath());
 }
コード例 #2
0
 public function invalidate($key)
 {
     $this->cache->delete($key);
 }