Saves data in the cache.
public set ( string $entryIdentifier, string $data, array $tags = [], integer $lifetime = null ) : void | ||
$entryIdentifier | string | An identifier for this specific cache entry |
$data | string | The data to be stored |
$tags | array | Tags to associate with this cache entry. If the backend does not support tags, this option can be ignored. |
$lifetime | integer | Lifetime of this cache entry in seconds. If NULL is specified, the default lifetime is used. "0" means unlimited lifetime. |
return | void |
/** * @test */ public function expiredEntriesAreSkippedWhenIterating() { $this->backend->set('entry1', 'foo', [], 1); sleep(2); $this->assertFalse($this->backend->has('entry1')); $actualEntries = []; foreach ($this->backend as $key => $value) { $actualEntries[] = $key; } $this->assertEmpty($actualEntries, 'Entries should be empty'); }
/** * @test */ public function setAddsEntryToRedis() { $this->redis->expects($this->any())->method('multi')->willReturn($this->redis); $this->redis->expects($this->once())->method('set')->with('Foo_Cache:entry:entry_1', 'foo')->willReturn($this->redis); $this->backend->set('entry_1', 'foo'); }