本文整理汇总了PHP中Predis\ClientInterface::get方法的典型用法代码示例。如果您正苦于以下问题:PHP ClientInterface::get方法的具体用法?PHP ClientInterface::get怎么用?PHP ClientInterface::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Predis\ClientInterface
的用法示例。
在下文中一共展示了ClientInterface::get方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: read
/**
* {@inheritdoc}
*/
public function read($sessionId)
{
if ($data = $this->redis->get($sessionId)) {
return $data;
}
return '';
}
示例2: doFetch
/**
* {@inheritdoc}
*/
protected function doFetch($id)
{
$result = $this->client->get($id);
if (null === $result) {
return false;
}
return unserialize($result);
}
示例3: read
/**
* 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);
}
示例4: testCacheSet
/**
* @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: getPosts
/**
* @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: preRequestHandle
/**
* @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: get
/**
* @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: testSetRange
/**
* @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: get
/**
* {@inheritDoc}
*/
public function get($key)
{
return $this->predis->get($key);
}
示例10: cacheGet
/**
* Get the cached token for a key.
*
* @param $key
* @return string
*/
protected function cacheGet($key)
{
$cachedToken = $this->client->get($key);
return $cachedToken;
}
示例11: get
/**
* 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: fetch
/**
* Fetch some data from the cache with this key
*
* @param $key
* @return string
*/
public function fetch($key)
{
return $this->redisClient->get($key);
}