本文整理汇总了PHP中Perf::getCacheService方法的典型用法代码示例。如果您正苦于以下问题:PHP Perf::getCacheService方法的具体用法?PHP Perf::getCacheService怎么用?PHP Perf::getCacheService使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Perf
的用法示例。
在下文中一共展示了Perf::getCacheService方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: clearForumsCache
function clearForumsCache($tableName, $fields)
{
$fids = isset($fields['fid']) ? is_array($fields['fid']) ? $fields['fid'] : array($fields['fid']) : null;
$_cacheService = Perf::getCacheService();
switch ($tableName) {
case 'pw_forums':
$_cacheService->delete('all_forums_info');
break;
case 'pw_forumdata':
$_cacheService->delete('all_forums_info');
if ($fids) {
foreach ($fids as $fourmId) {
$_cacheService->delete('forumdata_announce_' . $fourmId);
}
break;
}
case 'pw_announce':
$query = $GLOBALS['db']->query('SELECT fid FROM pw_forumdata');
while ($rt = $GLOBALS['db']->fetch_array($query)) {
$_cacheService->delete('forumdata_announce_' . $rt['fid']);
}
break;
default:
break;
}
}
示例2: extract
//info deploy
if (isset($deployfids['info'])) {
$cate_img = 'open';
$cate_info = 'none';
} else {
$cate_img = 'fold';
$cate_info = '';
}
// update birth day
if ($db_indexshowbirth) {
$brithcache = '';
require_once R_P . 'require/birth.php';
}
// get bbsinfo
if (Perf::checkMemcache()) {
$_cacheService = Perf::getCacheService();
$_bbsInfoResult = $_cacheService->get('bbsinfo_id_1');
if (!$_bbsInfoResult) {
$_bbsInfoService = L::loadClass('BbsInfoService', 'forum');
$_bbsInfoResult = $_bbsInfoService->getBbsInfoById(1);
}
extract($_bbsInfoResult);
} else {
extract($db->get_one("SELECT * FROM pw_bbsinfo WHERE id=1"));
}
$newmember = '<a href="u.php?username=' . rawurlencode($newmember) . '" target="_blank" class=" _cardshow" data-card-url="pw_ajax.php?action=smallcard&type=showcard&username=' . rawurlencode($newmember) . '" data-card-key=' . $newmember . '>' . $newmember . '</a>';
$article += $o_post;
$topics += $o_post;
$tposts += $o_tpost;
// online users
Update_ol();
示例3: getUserByUid
/**
* 获取用户信息
*
* @global DB $db
* @param int $uid
* @return array
*/
function getUserByUid($uid)
{
$uid = S::int($uid);
if ($uid < 1) {
return false;
}
if (perf::checkMemcache()) {
$_cacheService = Perf::getCacheService();
$detail = $_cacheService->get('member_all_uid_' . $uid);
if ($detail && in_array(SCR, array('index', 'read', 'thread', 'post'))) {
$_singleRight = $_cacheService->get('member_singleright_uid_' . $uid);
$detail = $_singleRight === false ? false : (array) $detail + (array) $_singleRight;
}
if ($detail) {
return $detail && $detail['groupid'] != 0 && isset($detail['md.uid']) ? $detail : false;
}
$cache = perf::gatherCache('pw_members');
if (in_array(SCR, array('index', 'read', 'thread', 'post'))) {
$detail = $cache->getMembersAndMemberDataAndSingleRightByUserId($uid);
} else {
$detail = $cache->getAllByUserId($uid, true, true);
}
return $detail && $detail['groupid'] != 0 && isset($detail['md.uid']) ? $detail : false;
} else {
global $db;
$sqladd = $sqltab = '';
if (in_array(SCR, array('index', 'read', 'thread', 'post'))) {
$sqladd = SCR == 'post' ? ',md.postcheck,sr.visit,sr.post,sr.reply' : (SCR == 'read' ? ',sr.visit,sr.reply' : ',sr.visit');
$sqltab = "LEFT JOIN pw_singleright sr ON m.uid=sr.uid";
}
$detail = $db->get_one("SELECT m.uid,m.username,m.password,m.safecv,m.email,m.bday,m.oicq,m.groupid,m.memberid,m.groups,m.icon,m.regdate,m.honor,m.timedf,m.style,m.datefm,m.t_num,m.p_num,m.yz,m.newpm,m.userstatus,m.shortcut,m.medals,m.gender,md.lastmsg,md.postnum,md.rvrc,md.money,md.credit,md.currency,md.lastvisit,md.thisvisit,md.onlinetime,md.lastpost,md.todaypost,md.monthpost,md.onlineip,md.uploadtime,md.uploadnum,md.starttime,md.pwdctime,md.monoltime,md.digests,md.f_num,md.creditpop,md.jobnum,md.lastgrab,md.follows,md.fans,md.newfans,md.newreferto,md.newcomment,md.punch,md.bubble,md.newnotice,md.newrequest,md.shafa {$sqladd} FROM pw_members m LEFT JOIN pw_memberdata md ON m.uid=md.uid {$sqltab} WHERE m.uid=" . S::sqlEscape($uid) . " AND m.groupid<>'0' AND md.uid IS NOT NULL");
return $detail;
}
}
示例4: changeForumDataWithForumId
/**
* 当发帖和发回复时,从memcache读取缓存数据然后更新它,而不是直接删除缓存
*
* @param array $information
* @return boolean
*/
function changeForumDataWithForumId($information = null)
{
if (!Perf::checkMemcache()) {
return true;
}
if (!S::isArray($information) || !($information = current($information)) || !isset($information['fid'])) {
return false;
}
$fid = intval($information['fid']);
$_cacheService = Perf::getCacheService();
$_cacheInfo = $_cacheService->get(array('all_forums_info', 'forumdata_announce_' . $fid));
$_unique = $GLOBALS['db_memcache']['hash'];
// 更新index页面里版块缓存
if (isset($_cacheInfo[$_unique . 'all_forums_info'])) {
$allForums = $_cacheInfo[$_unique . 'all_forums_info'];
foreach ($information as $key => $value) {
if (in_array($key, array('article', 'topic', 'tpost', 'subtopic'))) {
$allForums[$fid][$key] = $allForums[$fid][$key] + $value;
} else {
$allForums[$fid][$key] = $value;
}
}
$_cacheService->set('all_forums_info', $allForums, 300);
}
// 更新thread页面里版块和通告缓存
if (isset($_cacheInfo[$_unique . 'forumdata_announce_' . $fid])) {
$forums = $_cacheInfo[$_unique . 'forumdata_announce_' . $fid];
foreach ($information as $key => $value) {
if (in_array($key, array('article', 'topic', 'tpost', 'subtopic'))) {
$forums[$key] = $forums[$key] + $value;
} else {
$forums[$key] = $value;
}
}
$_cacheService->set('forumdata_announce_' . $fid, $forums, 300);
}
return true;
}