本文整理汇总了PHP中static_cache函数的典型用法代码示例。如果您正苦于以下问题:PHP static_cache函数的具体用法?PHP static_cache怎么用?PHP static_cache使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了static_cache函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getSourceInfo
/**
* 获取指定资源,并格式化输出
* @param string $table 资源表名
* @param integer $row_id 资源ID
* @param boolean $_forApi 是否提供API,默认为false
* @param string $appname 自定应用名称,默认为public
* @return [type] [description]
*/
public function getSourceInfo($table, $row_id, $_forApi = false, $appname = 'public')
{
static $forApi = '0';
$forApi == '0' && ($forApi = intval($_forApi));
$key = $forApi ? $table . $row_id . '_api' : $table . $row_id;
if ($info = static_cache('source_info_' . $key)) {
return $info;
}
switch ($table) {
case 'feed':
$info = $this->getInfoFromFeed($table, $row_id, $_forApi);
break;
case 'comment':
$info = $this->getInfoFromComment($table, $row_id, $_forApi);
break;
default:
$modelArr = explode('_', $table);
$model = '';
foreach ($modelArr as $v) {
$model .= ucfirst($v);
}
// 单独的内容,通过此路径获取资源信息
if (file_exists(SITE_PATH . '/apps/' . $appname . '/Lib/Model/' . $model . 'Model.class.php')) {
$info = D($model, $appname)->getSourceInfo($row_id, $_forApi);
}
break;
}
$info['source_table'] = $table;
$info['source_id'] = $row_id;
static_cache('source_info_' . $key, $info);
return $info;
}
示例2: getUserApp
/**
* 获取用户可用的应用列表
* @param integer $uid 用户UID
* @param integer $inweb 是否是Web端,默认为1
* @return array 用户可用的应用列表数据
*/
public function getUserApp($uid, $inweb = 1)
{
// 默认应用
if ($appList = static_cache('userApp_uapp_' . $uid . '_' . $inweb)) {
return $appList;
}
if (($appList = model('Cache')->get('userApp_uapp_' . $uid . '_' . $inweb)) === false) {
$appList = array();
//$return = model('App')->getDefaultApp();
$imap['a.uid'] = $uid;
$imap['a.inweb'] = intval($inweb);
$imap['b.status'] = 1;
$table = $this->tablePrefix . 'user_app AS a LEFT JOIN ' . $this->tablePrefix . 'app AS b ON a.app_id = b.app_id';
if ($list = $this->table($table)->where($imap)->field('a.app_id')->order('a.display_order ASC')->getAsFieldArray('app_id')) {
foreach ($list as $v) {
$appList[] = model('App')->getAppById($v);
}
}
/* if(!empty($return)){
$appList = empty($appList) ? $return :array_merge($return,$appList);
}*/
model('Cache')->set('userApp_uapp_' . $uid . '_' . $inweb, $appList, 120);
}
static_cache('userApp_uapp_' . $uid . '_' . $inweb, $appList);
return $appList;
}
示例3: getAttachById
/**
* 通过单个附件ID获取其附件信息
* @param int $id 附件ID
* @return array 指定附件ID的附件信息
*/
public function getAttachById($id)
{
$id = intval($id);
if (empty($id)) {
return false;
}
$name = 'ts_attach_id_' . $id;
$sc = S($name);
if (!$sc) {
// 获取静态缓存
$sc = static_cache('attach_infoHash_' . $id);
if (!empty($sc)) {
return $sc;
}
// 获取缓存
$sc = model('Cache')->get('Attach_' . $id);
if (empty($sc)) {
$map['attach_id'] = $id;
$sc = $this->where($map)->find();
empty($sc) && ($sc = array());
model('Cache')->set('Attach_' . $id, $sc, 3600);
}
static_cache('attach_infoHash_' . $id, $sc);
S($name, $sc);
}
return $sc;
}
示例4: getUserProfileSetting
/**
* 获取用户资料配置信息 - 不分页型
* @param array $map 查询条件
* @param string $order 排序条件
* @return array 用户资料配置信息
*/
public function getUserProfileSetting($map = null, $order = 'field_key, display_order ASC')
{
$key = md5(implode("", $map) . $order);
if ($setting = static_cache('profile_' . $key)) {
return $setting;
}
$setting = $this->_getUserProfileSetting($map, $order);
$setting = $this->_formatUserProfileSetting($setting);
static_cache('profile_' . $key, $setting);
return $setting;
}
示例5: getNodeList
/**
* 获取节点列表
* @return array 节点列表数据
*/
public function getNodeList()
{
// 缓存处理
if ($list = static_cache('notify_node')) {
return $list;
}
if (($list = model('Cache')->get('notify_node')) == false) {
$list = $this->getHashList('node', '*');
model('Cache')->set('notify_node', $list);
}
static_cache('notify_node', $list);
return $list;
}
示例6: getRemarkHash
/**
* 获取指定用户的备注列表
* @param integer $uid 用户ID
* @return array 指定用户的备注列表
*/
public function getRemarkHash($uid)
{
if (empty($uid)) {
return false;
}
if ($list = static_cache('follow_remark_' . $uid)) {
return $list;
}
$map['uid'] = $uid;
$map['remark'] = array('NEQ', '');
$list = $this->where($map)->getHashList('fid', 'remark');
static_cache('follow_remark_' . $uid, $list);
return $list;
}
示例7: cleanCache
/**
* 清除指定Game数据
*
*/
public function cleanCache($ids)
{
if (empty($ids)) {
return false;
}
!is_array($ids) && ($ids = explode(',', $ids));
foreach ($ids as $id) {
static_cache('master_info_' . $id, false);
$keys = S('master_info_' . $id);
foreach ($keys as $k) {
S($k, null);
}
S('master_info_' . $id, null);
}
return true;
}
示例8: getUserSpace
/**
* 返回解析空间地址
* @param integer $uid 用户ID
* @param string $class 样式类
* @param string $target 是否进行跳转
* @param string $text 标签内的相关内容
* @param boolen $icon 是否显示用户组图标,默认为true
* @return string 解析空间地址HTML
*/
function getUserSpace($uid, $class, $target, $text, $icon = true)
{
// 2.8转移
// 静态变量
static $_userinfo = array();
// 判断是否有缓存
if (!isset($_userinfo[$uid])) {
$_userinfo[$uid] = model('User')->getUserInfo($uid);
}
// 配置相关参数
empty($target) && ($target = '_self');
empty($text) && ($text = $_userinfo[$uid]['uname']);
// 判断是否存在替换信息
preg_match('|{(.*?)}|isU', $text, $match);
if ($match) {
if ($match[1] == 'uname') {
$text = str_replace('{uname}', $_userinfo[$uid]['uname'], $text);
//empty($class) && $class = 'username'; //2013/2/28 wanghaiquan
empty($class) && ($class = 'name');
} else {
preg_match("/{uavatar}|{uavatar\\=(.*?)}/e", $text, $face_type);
switch ($face_type[1]) {
case 'b':
$userface = 'big';
break;
case 'm':
$userface = 'middle';
break;
default:
$userface = 'small';
break;
}
$face = $_userinfo[$uid]['avatar_' . $userface];
$text = '<img src="' . $face . '" />';
empty($class) && ($class = 'userface');
$icon = false;
}
}
// 组装返回信息
$user_space_info = '<a event-node="face_card" uid="' . $uid . '" href="' . $_userinfo[$uid]['space_url'] . '" class="' . $class . '" target="' . $target . '">' . $text . '</a>';
// 用户认证图标信息
if ($icon) {
$group_icon = array();
$user_group = static_cache('usergrouplink_' . $uid);
if (!$user_group) {
$user_group = model('UserGroupLink')->getUserGroupData($uid);
static_cache('usergrouplink_' . $uid, $user_group);
}
// if(!empty($user_group)) {
// foreach($user_group[$uid] as $value) {
// $group_icon[] = '<img title="'.$value['user_group_name'].'" src="'.$value['user_group_icon_url'].'" class="space-group-icon" />';
// }
// $user_space_info .= ' '.implode(' ', $group_icon);
// }
$union = model('Union')->getUnionState($GLOBALS['mid'], $uid);
if ($union['unioning'] == 1 && $union['unioner'] == 1) {
$user_space_info .= ' <img title="联盟" src="' . SITE_URL . '/addons/theme/stv1/_static/image/usergroup/union.png" class="space-group-icon" />';
}
}
return $user_space_info;
}
示例9: _getUserInfo
/**
* 获取指定用户的相关信息
*
* @param array $map
* 查询条件
* @return array 指定用户的相关信息
*/
private function _getUserInfo($map, $field = "*")
{
$user = $this->getUserDataByCache($map, $field);
unset($user['password']);
if (!$user) {
$this->error = L('PUBLIC_GET_INFORMATION_FAIL');
// 获取用户信息失败
return false;
} else {
$uid = $user['uid'];
$user = array_merge($user, model('Avatar')->init($user['uid'])->getUserAvatar());
$user['avatar_url'] = U('public/Attach/avatar', array('uid' => $user["uid"]));
$user['space_url'] = !empty($user['domain']) ? U('public/Profile/index', array('uid' => $user["domain"])) : U('public/Profile/index', array('uid' => $user["uid"]));
$user['space_link'] = "<a href='" . $user['space_url'] . "' target='_blank' uid='{$user['uid']}' event-node='face_card'>" . $user['uname'] . "</a>";
$user['space_link_no'] = "<a href='" . $user['space_url'] . "' title='" . $user['uname'] . "' target='_blank'>" . $user['uname'] . "</a>";
// 用户勋章
$user['medals'] = model('Medal')->getMedalByUid($user['uid']);
// 用户认证图标
$groupIcon = array();
$userGroup = model('UserGroupLink')->getUserGroupData($uid);
$user['user_group'] = $userGroup[$uid];
foreach ($userGroup[$uid] as $value) {
$groupIcon[] = '<img title="' . $value['user_group_name'] . '" src="' . $value['user_group_icon_url'] . '" style="width:auto;height:auto;display:inline;cursor:pointer;" />';
}
$user['group_icon'] = implode(' ', $groupIcon);
model('Cache')->set('ui_' . $uid, $user, 600);
static_cache('user_info_' . $uid, $user);
return $user;
}
}
示例10: getCommentInfo
/**
* 获取评论信息
* @param integer $id 评论ID
* @param boolean $source 是否显示资源信息,默认为true
* @return array 获取评论信息
*/
public function getCommentInfo($id, $source = true)
{
$id = intval($id);
if (empty($id)) {
$this->error = L('PUBLIC_WRONG_DATA');
// 错误的参数
return false;
}
if ($info = static_cache('comment_info_' . $id)) {
return $info;
}
$map['comment_id'] = $id;
$info = $this->where($map)->find();
$info['user_info'] = model('User')->getUserInfo($info['uid']);
$info['content'] = $info['content'];
/* 解析出emoji */
$info['content'] = formatEmoji(false, $info['content']);
$source && ($info['sourceInfo'] = model('Source')->getCommentSource($info));
static_cache('comment_info_' . $id, $info);
return $info;
}
示例11: _returnData
/**
* 返回缓存数据操作,方法中,将数据缓存到静态缓存中
* @param mix $data 缓存数据
* @param string $key 缓存Key值
* @return mix 缓存数据
*/
private function _returnData($data, $key)
{
// TODO:可以在此对空值进行处理判断
static_cache('cache_' . $key, $data);
return $data;
}
示例12: getCommentInfo
/**
* 获取评论信息
* @param integer $id 评论ID
* @param boolean $source 是否显示资源信息,默认为true
* @return array 获取评论信息
*/
public function getCommentInfo($id, $source = true)
{
if (empty($id)) {
$this->error = L('PUBLIC_WRONG_DATA');
// 错误的参数
return false;
}
if ($info = static_cache('comment_info_' . $id)) {
return $info;
}
$map['comment_id'] = $id;
$info = $this->where($map)->find();
$info['user_info'] = model('User')->getUserInfo($info['uid']);
//$info['content'] = parse_html($info['content']);
$info['content'] = $info['content'];
// 2012/12/7修改
$source && ($info['sourceInfo'] = model('Source')->getSourceInfo($info['table'], $info['row_id'], false, $info['app']));
static_cache('comment_info_' . $id, $info);
return $info;
}
示例13: convertUidToPath
/**
* 将用户的UID转换为三级路径
* @param integer $uid 用户UID
* @return string 用户路径
*/
public function convertUidToPath($uid)
{
// 静态缓存
$sc = static_cache('avatar_uidpath_' . $uid);
if (!empty($sc)) {
return $sc;
}
$md5 = md5($uid);
$sc = '/' . substr($md5, 0, 2) . '/' . substr($md5, 2, 2) . '/' . substr($md5, 4, 2);
static_cache('avatar_uidpath_' . $uid, $sc);
return $sc;
}
示例14: _getUserInfo
/**
* 获取指定用户的相关信息
*
* @param array $map
* 查询条件
* @return array 指定用户的相关信息
*/
private function _getUserInfo(array $map, $field = '*')
{
$user = $this->getUserDataByCache($map, $field);
unset($user['password']);
if (!$user) {
$this->error = L('PUBLIC_GET_INFORMATION_FAIL');
// 获取用户信息失败
return false;
} else {
$uid = $user['uid'];
$user = array_merge($user, model('Avatar')->init($user['uid'])->getUserAvatar());
$user['avatar_url'] = U('public/Attach/avatar', array('uid' => $user["uid"]));
$user['space_url'] = !empty($user['domain']) ? U('public/Profile/index', array('uid' => $user["domain"])) : U('public/Profile/index', array('uid' => $user["uid"]));
$user['space_link'] = "<a href='" . $user['space_url'] . "' target='_blank' uid='{$user['uid']}' event-node='face_card'>" . $user['uname'] . "</a>";
$user['space_link_no'] = "<a href='" . $user['space_url'] . "' title='" . $user['uname'] . "' target='_blank'>" . $user['uname'] . "</a>";
// 用户勋章
$user['medals'] = model('Medal')->getMedalByUid($user['uid']);
// 用户认证图标
$groupIcon = $authIcon = array();
$aIcon[5] = '<i class="type-trade"></i>';
$aIcon[6] = '<i class="type-hangjia"></i>';
$aIcon[7] = '<i class="type-daren"></i>';
$userGroup = model('UserGroupLink')->getUserGroupData($uid);
$user['api_user_group'] = $userGroup[$uid];
$user['user_group'] = $userGroup[$uid];
$only = array(array(), array());
// $authenticate = array();
foreach ($userGroup[$uid] as $value) {
($value['user_group_id'] == 5 || $value['user_group_id'] == 6) && ($value['company'] = M('user_verified')->where("uid={$uid} and usergroup_id=" . $value['user_group_id'])->getField('company'));
if ($value['is_authenticate'] == 1) {
$authIcon[] = $aIcon[$value['user_group_id']];
$authenticate[$value['user_group_id']] = $value;
}
$groupIcon[] = '<img title="' . $value['user_group_name'] . '" src="' . $value['user_group_icon_url'] . '" style="width:auto;height:auto;display:inline;cursor:pointer;" />';
$type = $value['is_authenticate'] ? 1 : 0;
if (empty($only[$type])) {
$only[$type] = $value;
} elseif ($only[$type]['ctime'] < $value['ctime']) {
$only[$type] = $value;
}
}
if (!empty($only[0])) {
$user['group_icon_only'] = $only[0];
} elseif (!empty($only[1])) {
$user['group_icon_only'] = $only[1];
} else {
$user['group_icon_only'] = array();
}
/*group_icon_only end*/
$user['group_icon'] = implode(' ', $groupIcon);
//$user ['auth_icon'] = implode ( ' ', $authIcon );
$user['credit_info'] = model('Credit')->getUserCredit($uid);
model('Cache')->set('ui_' . $uid, $user, 600);
static_cache('user_info_' . $uid, $user);
return $user;
}
}
示例15: getUserGroupByGids
/**
* 通过指定用户组ID获取用户组信息
* @param string|array $gids 用户组ID
* @return array 指定用户组ID获取用户组信息
*/
public function getUserGroupByGids($gids)
{
$data = static_cache('UserGroupByGid' . implode(',', $gids));
if ($data) {
return $data;
}
!is_array($gids) && ($gids = explode(',', $gids));
if (empty($gids)) {
return false;
}
$map['user_group_id'] = array('IN', $gids);
$data = $this->where($map)->findAll();
static_cache('UserGroupByGid' . implode(',', $gids), $data);
return $data;
}