本文整理汇总了PHP中Redis::get方法的典型用法代码示例。如果您正苦于以下问题:PHP Redis::get方法的具体用法?PHP Redis::get怎么用?PHP Redis::get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Redis
的用法示例。
在下文中一共展示了Redis::get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get
/**
* Returns cached value by key
*
* @param string $key
* @return bool|mixed
*/
public function get($key)
{
if (false === ($value = $this->cache->get($this->prepareKey($key)))) {
return false;
}
return $this->unserializeCompound($value);
}
示例2: read
/**
* @inheritDoc
*/
public function read($id)
{
if ($data = $this->_redis->get($this->getPrefixKey($id))) {
return unserialize($data);
}
return null;
}
示例3: retrieve
/**
* @inheritdoc
*/
public function retrieve($key)
{
if (!$this->exists($key)) {
return null;
}
return unserialize($this->redis->get($this->prefix . $key));
}
示例4: increment
public static function increment($host)
{
$count = self::$redis->incrBy(self::$prefix . $host, 1);
if (self::$redis->get(self::$prefix . $host) == 1) {
self::$redis->setTimeout(self::$prefix . $host, self::$ttl);
}
return $count;
}
示例5: get
/**
* Attempt to retrieve a value from the cache server, if not set it.
*
* @param string $key Key we can use to retrieve the data.
*
* @return bool|string False on failure or String, data belonging to the key.
* @access public
*/
public function get($key)
{
if ($this->connected === true && $this->ping() === true) {
$data = $this->server->get($key);
return $this->isRedis ? $this->IgBinarySupport ? igbinary_unserialize($data) : unserialize($data) : $data;
}
return false;
}
示例6: load
/**
* Loads item by cache key.
*
* @param string $key
* @return mixed
*
* @throws StorageException if storage error occurs, handler can not be used
*/
protected function load($key)
{
try {
return $this->redis->get($key);
} catch (\Exception $e) {
throw new StorageException("Failed to load redis key: {$key}", 1, $e);
}
}
示例7: get
/**
* Get cache
*
* @param string Cache ID
* @return mixed
*/
public function get($key)
{
$value = $this->_redis->get($key);
if ($value !== FALSE && isset($this->_serialized[$key])) {
return unserialize($value);
}
return $value;
}
示例8: get
/**
* Get a cache variable
*
* Retrieve a variable from the cache and return it's
* value to the user.
*
* @param string $name The name of the cache variable to retrieve.
*
* @return mixed The value of the retrieved variable or false if
* variable isn't found.
*/
public function get($name)
{
$key = $this->redis->get($name);
if ($key !== false) {
return unserialize($key);
}
return false;
}
示例9: get
/**
* get var
* @param $key
* @param null $default
* @return bool|mixed
*/
public function get($key, $default = null)
{
$result = $this->redis->get($key);
if ($result) {
return $result;
}
return $default;
}
示例10: getMy
/**
* @param $key
* @return Option
*/
public static function getMy($key)
{
$hash = self::hash($key);
if (self::$redis->exists(self::myPrefix() . ":" . $hash)) {
return Option::Some(unserialize(self::$redis->get(self::myPrefix() . ":" . $hash)));
} else {
return Option::None();
}
}
示例11: get
public function get($key)
{
$result = self::$cache->get($this->getNamespace() . $key);
if ($result === false && !self::$cache->exists($this->getNamespace() . $key)) {
return null;
} else {
return json_decode($result, true);
}
}
示例12: get
public function get($id, $default = NULL)
{
// Get the value from Redis
$value = $this->_redis->get($id);
if ($value == false) {
$value = $default;
}
// Return the value
return $value;
}
示例13: loadUserByOauth
/**
* @param int $provider
* @param int $providerUserId
*
* @return bool|User
*
*/
public function loadUserByOauth($provider, $providerUserId)
{
if (!($userName = $this->redis->get('credentials:' . implode(':', array($provider, $providerUserId))))) {
return false;
}
if (!($user = $this->loadUserByUsername($userName))) {
return false;
}
return new User($user);
}
示例14: testStdClass
public function testStdClass()
{
$data = new \stdClass();
$data->a = 'a';
$data->b = 'b';
$key = new CacheKey('test', rand(1, 1000));
$this->cache->set($key, $data);
$val = $this->cache->get($key);
$this->assertEquals($data, $val);
}
示例15: __construct
public function __construct()
{
$redis = new Redis();
try {
$redis->connect('127.0.0.1', 6379);
$this->data = array('count' => $redis->get('cobbler:count'), 'speed' => $redis->get('cobbler:speed'));
$redis->close();
} catch (Exception $e) {
$this->error(500, $e->getMessage());
}
}