예제 #1
0
 /**
  * {@inheritdoc}
  */
 public function read($sessionId)
 {
     if ($data = $this->redis->get($sessionId)) {
         return $data;
     }
     return '';
 }
예제 #2
0
 /**
  * {@inheritdoc}
  */
 protected function doFetch($id)
 {
     $result = $this->client->get($id);
     if (null === $result) {
         return false;
     }
     return unserialize($result);
 }
예제 #3
0
 /**
  * Read a key from the cache
  *
  * @param string $key Identifier for the data
  * @return mixed The cached data, or false if the data doesn't exist, has expired, or if there was an error fetching it
  */
 public function read($key)
 {
     $key = $this->_key($key);
     $value = $this->client->get($key);
     if ($value === null) {
         return false;
     }
     return ctype_digit($value) ? (int) $value : unserialize($value);
 }
 /**
  * @test
  */
 public function testCacheSet()
 {
     $token = $this->tokenProvider->getAccessTokenByToken('nnch734d00sl2jdk');
     $serializedToken = serialize($token);
     $key = 'tokenProvider/token/key:nnch734d00sl2jdk';
     $this->tokenProviderCache->cacheSet($key, $serializedToken);
     $cachedToken = $this->client->get($key);
     $this->assertEquals($serializedToken, $cachedToken);
 }
예제 #5
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);
 }
예제 #6
0
 /**
  * @param SessionInterface $session
  * @param Request $request
  */
 private function preRequestHandle(SessionInterface $session, Request $request)
 {
     $id = $request->cookie($this->key);
     $key = 'session:' . $id;
     if (!Str::equals($key, $session->getId())) {
         $this->redis->del($key);
         return;
     }
     $value = $this->redis->get('session:' . $key);
     $content = Json::parse($value);
     if ($content['last_seen'] > $session->get('last_seen')) {
         foreach ($content as $key => $value) {
             if (!Str::startsWith($key, ['_', 'login_'])) {
                 $session->set($key, $value);
             }
         }
     }
 }
예제 #7
0
파일: Service.php 프로젝트: spryker/Storage
 /**
  * @param string $key
  *
  * @return mixed
  */
 public function get($key)
 {
     $key = $this->getKeyName($key);
     $value = $this->client->get($key);
     $this->addReadAccessStats($key);
     $result = json_decode($value, true);
     if (json_last_error() === \JSON_ERROR_SYNTAX) {
         return $value;
     }
     return $result;
 }
예제 #8
0
파일: PredisTest.php 프로젝트: gmo/cache
 /**
  * @group redis-strings
  */
 public function testSetRange()
 {
     $this->assertSame(9, $this->client->setrange('foo', 4, 'World'));
     $this->assertSame("World", $this->client->get('foo'));
     $this->client->set('foo', 'Hello World');
     $this->assertSame(14, $this->client->setrange('foo', 6, 'Universe'));
     $this->assertSame('Hello Universe', $this->client->get('foo'));
     $this->client->set('foo', 'bar');
     $this->assertSame(9, $this->client->setrange('foo', 6, 'baz'));
     $this->assertSame("barbaz", $this->client->get('foo'));
 }
예제 #9
0
 /**
  * {@inheritDoc}
  */
 public function get($key)
 {
     return $this->predis->get($key);
 }
 /**
  * Get the cached token for a key.
  *
  * @param $key
  * @return string
  */
 protected function cacheGet($key)
 {
     $cachedToken = $this->client->get($key);
     return $cachedToken;
 }
예제 #11
0
 /**
  * Gets a cache entry
  * returning null if not in cache
  *
  * @param $key
  * @return null|mixed
  */
 public function get($key)
 {
     return $this->serializer->deserialize($this->client->get($key));
 }
예제 #12
0
 /**
  * Fetch some data from the cache with this key
  *
  * @param $key
  * @return string
  */
 public function fetch($key)
 {
     return $this->redisClient->get($key);
 }