本文整理匯總了PHP中Redis::hget方法的典型用法代碼示例。如果您正苦於以下問題:PHP Redis::hget方法的具體用法?PHP Redis::hget怎麽用?PHP Redis::hget使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Redis
的用法示例。
在下文中一共展示了Redis::hget方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: isCached
protected function isCached(Bookmark $bookmark, $redisKey)
{
if ($this->redis !== null) {
return $this->redis->hget($redisKey, $bookmark->url);
}
return false;
}
示例2: setting
/**
* Get or set setting
*
* @param string $name
* @param string|int $value
* @return mixed
*/
public function setting($name, $value = null)
{
if ($value) {
$this->client->hset('q:settings', $name, $value);
return $this;
}
return $this->client->hget('q:settings', $name);
}
示例3: Redis
<?php
header("Content-Type: text/html;charset=utf-8");
$cookie = $_POST["Cookie"];
$redis = new Redis();
$redis->connect('127.0.0.1', 6379);
if (strpos($cookie, "DedeUserID") === FALSE or strpos($cookie, "DedeUserID__ckMd5") === FALSE or strpos($cookie, "SESSDATA") === FALSE) {
echo "<script>alert('Cookie數據不符合要求,請重試!');history.go(-1);</script>";
exit;
}
$keyname = preg_replace('{(.*)?DedeUserID=([\\d]+);(.*)?}', '$2', $cookie);
if ($redis->exists($keyname)) {
$status = $redis->hget($keyname, 'status');
$cookieexist = $redis->hget($keyname, 'cookie');
if ($status == 'processing') {
echo "<script>alert('正在為你領取銀瓜子~');history.go(-1);</script>";
exit;
} elseif ($status == 'processed') {
echo "<script>alert('今天的銀瓜子已經領完了,明天再來吧~');history.go(-1);</script>";
exit;
} elseif ($status == 'problem') {
if ($cookieexist == $cookie) {
echo "<script>alert('Cookie數據有問題,請嘗試重新登錄獲取後再提交!');history.go(-1);</script>";
exit;
} else {
echo "<script>alert('成功更新Cookie數據!');</script>";
}
} else {
echo "<script>alert('你的任務正在隊列中,稍後再看看吧~');history.go(-1);</script>";
exit;
}
示例4: Redis
$log->info("Starting feedwriter process");
// Connect to redis
$redis = new Redis();
while (!$redis->connect("127.0.0.1")) {
sleep(1);
$log->warn("Could not connect to redis, retrying");
}
require "Modules/feed/engine/PHPTimeSeries.php";
require "Modules/feed/engine/PHPFina.php";
$engine = array();
$engine[Engine::PHPTIMESERIES] = new PHPTimeSeries($feed_settings['phptimeseries']);
$engine[Engine::PHPFINA] = new PHPFina($feed_settings['phpfina']);
while (true) {
$len = $redis->llen("feedbuffer");
for ($i = 0; $i < $len; $i++) {
$f = explode(",", $redis->lpop("feedbuffer"));
$feedid = $f[0];
$timestamp = $f[1];
$value = $f[2];
$padding_mode = (int) $f[3];
$e = $redis->hget("feed:{$feedid}", 'engine');
if ($padding_mode == 1) {
$engine[Engine::PHPFINA]->padding_mode = 'join';
}
$engine[$e]->prepare($feedid, $timestamp, $value);
$engine[Engine::PHPFINA]->padding_mode = 'nan';
}
$log->info("PHPTimeSeries bytes written: " . $engine[Engine::PHPTIMESERIES]->save());
$log->info("PHPFina bytes written: " . $engine[Engine::PHPFINA]->save());
sleep(60);
}
示例5: hget
public function hget($prefix, $key)
{
$data = unserialize(parent::hget($this->generateUniqueKey($prefix), $key));
if (!is_array($data)) {
return false;
}
if (isset($data[1]) && (!$data[1] instanceof ICacheDependency || !$data[1]->getHasChanged())) {
return $data[0];
}
return false;
}
示例6: hget
/**
* Increment a raw value
*
* @param string $id Cache ID
* @param int $offset Step/value to add
* @return mixed New value on success or FALSE on failure
*/
public function hget($alias, $key)
{
return $this->_redis->hget($alias, $key);
}
示例7: count
//同一個文件服務安裝的次數
foreach ($res as $k => $v) {
for ($i = 0; $i < count($v); $i++) {
$arr_num[$k] = count($v);
$cont[] = count($v) . ',' . $k . ',' . $v[$i][1] . ',' . $date;
}
}
//print_r($cont);die;
for ($i = 0; $i < count($cont); $i++) {
$cont_arr[] = explode(",", $cont[$i]);
}
//print_r($cont_arr);die;
$redis = new Redis();
$redis->connect('127.0.0.1', 6379);
foreach ($cont_arr as $key => $val) {
$vals[] = $redis->hget("server", $val[2]);
if ($vals) {
$redis->hdel("server", $val[2]);
$redis->hset("server", $val[2], json_encode($val));
} else {
$redis->hset("server", $val[2], json_encode($val));
}
}
//print_r($redis->hGetAll("server"));die;
/*
* Mbr 日 啟 動 統 計
*/
//信息分割成數組
for ($i = 0; $i < count($install); $i++) {
$info_arr[] = explode(",", $install[$i]);
}
示例8: hget
public function hget($key, $hash, $serialize = true)
{
return $serialize ? unserialize($this->handler->hget($key, $hash)) : $this->handler->hget($key, $hash);
}
示例9: rand
print_r($data);
for ($i = 0; $i < 10; $i++) {
$redis->zadd("zset", $i + rand(10, 99), $i + rand(100, 999));
}
$data = $redis->zrange("zset", 0, 3, "withscores");
echo "<pre>";
print_r($data);
$redis->zrem("zset", 456);
echo $redis->zcount("zset", 10, 50);
$redis->zRemRangeByScore("key", star, end);
echo $redis->zScore("zset", 503);
echo $redis->zrank("zset", 723);
for ($i = 0; $i < 10; $i++) {
$redis->hset("myhash", $i, rand(10, 99) + $i);
}
echo $redis->hget("myhash", "0");
echo $redis->hlen("myhash");
echo $redis->hdel("myhash", "0");
$data = $redis->hkeys("myhash");
$data = $redis->hvals("myhash");
$data = $redis->hgetall("myhash");
echo "<pre>";
print_r($data);
echo $redis->hexists("myhash", "0");
$redis->hmset("user:1", array("name1" => "name1", "name2" => "Joe2"));
$data = $redis->hmget("user:1", array('name', 'salary'));
print_r($data);
// redis
$redis->move("key1", 2);
$redis->settimeout("user:1", 10);
$redis->expireat("myhash", time() + 23);
示例10: get
/**
* Get job property
*
* @param string $key
* @return mixed
*/
public function get($key)
{
return $this->client->hget('q:job:' . $this->injectors['id'], $key);
}
示例11: array
$users[] = $u;
}
//設置當前用戶信息
$redis->hMset("chatuser:{$sid}", array("name" => $info['name'], 'id' => $sid));
//返回用戶列表
$body = json_encode(array('type' => 'list', 'list' => $users));
header("Content-Length: " . strlen($body));
echo $body;
} else {
if ($info['type'] == 'join') {
//加入分組
$router->addChannel('chat-channel-' . $info['channel'], $sid);
} else {
if ($info['type'] == 'msg') {
//發送消息
$name = $redis->hget("chatuser:{$sid}", "name");
$info['text'] = str_replace(array('<', '>'), array('<', '>'), $info['text']);
if ($info['channel']) {
$router->publish('chat-channel-' . $info['channel'], json_encode(array('type' => 'msg', 'name' => $name, 'channel' => (int) $info['channel'], 'text' => $info['text'], 'time' => date('i:s'))));
} else {
$router->sendAllMsg(json_encode(array('type' => 'msg', 'name' => $name, 'channel' => 0, 'text' => $info['text'], 'time' => date('i:s'))));
}
}
}
}
} else {
if ($_SERVER['EVENT'] == 2) {
//斷開連接
$user = $redis->hgetall("chatuser:{$sid}");
if ($user) {
$redis->del("chatuser:{$sid}");