コード例 #1
0
ファイル: MemoryCacheTest.php プロジェクト: 0x20h/phloppy
 public function testExpire()
 {
     $key = uniqid();
     $c = new MemoryCache();
     $this->assertTrue($c->set($key, ['bar' => ['baz']], 1));
     $this->assertEquals(['bar' => ['baz']], $c->get($key));
     $this->assertTrue($c->expires($key) <= time() + 1);
     sleep(2);
     $this->assertNull($c->get($key));
     $this->assertEquals(0, $c->expires('foobar'));
 }
コード例 #2
0
ファイル: FileCache.php プロジェクト: 0x20h/phloppy
 /**
  * Cache the given Nodes.
  *
  * @param string   $key
  * @param string[] $nodes
  * @param int      $ttl TTL in seconds
  *
  * @return bool
  */
 public function set($key, array $nodes, $ttl)
 {
     $this->read();
     parent::set($key, $nodes, $ttl);
     return $this->write();
 }