Example #1
0
 /**
  * @group redis-keys
  */
 public function testExpireAt()
 {
     $this->assertFalse($this->client->expire('foo', 1));
     $this->client->set('foo', 'bar');
     $this->assertTrue($this->client->expireat('foo', time() + 1));
     usleep(1500000.0);
     $this->assertFalse($this->client->exists('foo'));
 }
Example #2
0
 /**
  * @return array
  */
 public function getPosts() : array
 {
     if ($this->redisClient !== null) {
         $posts = $this->redisClient->get('posts');
         if ($posts) {
             return json_decode($posts, true);
         }
     }
     $blog = $this->getBlogInfo();
     $posts = $this->thumblrClient->getBlogPosts($blog['name'], ['type' => 'text'])->posts;
     $posts = json_encode($posts, JSON_PRETTY_PRINT);
     if ($this->redisClient !== null) {
         $this->redisClient->set('posts', $posts);
         $this->redisClient->expireat('posts', time() + 3600);
     }
     return json_decode($posts, true);
 }