コード例 #1
0
ファイル: TryCatchWrapper.php プロジェクト: plista/core-redis
 /**
  * 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());
     }
 }
コード例 #2
0
 /**
  * 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'));
 }