/** * Remove the expiration timer from a key. * * @param string $key * * @return bool: TRUE if a timeout was removed, FALSE if the key didn’t exist or didn’t have an expiration timer. * @link http://redis.io/commands/persist * @example $redis->persist('key'); */ public function persist($key) { try { return $this->client->persist($key); } catch (Exception $e) { return $this->handleException($e, __FUNCTION__, func_get_args()); } }
/** * Test persisting a key */ public function testPersist() { $this->redis->del('testPersist'); $isPersisted = $this->redis->persist('testPersist'); $this->assertInternalType('bool', $isPersisted); $this->assertFalse($isPersisted); $this->redis->set('testPersist', 'someValue'); $this->assertFalse($this->redis->persist('testPersist')); $this->redis->expire('testPersist', 1); $isPersisted = $this->redis->persist('testPersist'); $this->assertInternalType('bool', $isPersisted); $this->assertTrue($isPersisted); sleep(2); $this->assertEquals('someValue', $this->redis->get('testPersist')); }