private function doTestWrongKeys(CachePeer $cache) { $cache->clean(); $value = 'a'; // unexist key $this->assertNull($cache->get('b')); $this->assertTrue($cache->isAlive()); $this->assertFalse($cache->replace('b', $value)); $this->assertTrue($cache->isAlive()); $this->assertFalse($cache->append('b', $value)); $this->assertTrue($cache->isAlive()); $this->assertNull($cache->increment('b', $value)); $this->assertTrue($cache->isAlive()); $this->assertNull($cache->decrement('b', $value)); $this->assertTrue($cache->isAlive()); $this->assertFalse($cache->delete('b')); $this->assertTrue($cache->isAlive()); // wrong key $this->assertNull($cache->get(null)); $this->assertTrue($cache->isAlive()); $this->assertFalse($cache->replace(null, $value)); $this->assertTrue($cache->isAlive()); $this->assertFalse($cache->append(null, $value)); $this->assertTrue($cache->isAlive()); $this->assertNull($cache->increment(null, $value)); $this->assertTrue($cache->isAlive()); $this->assertNull($cache->decrement(null, $value)); $this->assertTrue($cache->isAlive()); $this->assertFalse($cache->delete(null)); $this->assertTrue($cache->isAlive()); $cache->clean(); }
/** * Sets the value only if it is already defined by key * @return CachePeer */ function replace($key, $value, $ttl = CacheTtl::HOUR) { return $this->peer->replace($this->mangleKey($key), $value, $ttl); }