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')); }
/** * 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(); }