本文整理汇总了PHP中wcache函数的典型用法代码示例。如果您正苦于以下问题:PHP wcache函数的具体用法?PHP wcache怎么用?PHP wcache使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wcache函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: circleInfoOp
/**
* GET 圈子详情
*/
public function circleInfoOp()
{
$c_id = $_GET['circle_id'];
if ($c_id != '' && $c_id > 0) {
$circle_info = Model()->table('circle')->find($c_id);
if (empty($circle_info)) {
output_error("圈子不存在");
die;
}
//圈主和管理员信息
$prefix = 'circle_managelist';
$manager_list = rcache($this->c_id, $prefix);
if (empty($manager_list)) {
$manager_list = Model()->table('circle_member')->where(array('circle_id' => $this->c_id, 'is_identity' => array('in', array(1, 2))))->page($this->page)->select();
$manager_list = array_under_reset($manager_list, 'is_identity', 2);
$manager_list[2] = array_under_reset($manager_list[2], 'member_id', 1);
wcache($this->c_id, $manager_list, $prefix);
}
$circle_info['circle_masteravatar'] = getMemberAvatarForID($circle_info['circle_masterid']);
output_data(array('circle_info' => $circle_info, 'creator' => $manager_list[1][0], 'manager_list' => $manager_list[2]));
} else {
output_error("圈子id错误");
die;
}
}
示例2: getEvaluateGoodsInfoByGoodsID
/**
* 根据商品编号查询商品评价信息
*/
public function getEvaluateGoodsInfoByGoodsID($goods_id)
{
$prefix = 'evaluation_goods_info';
$info = rcache($goods_id, $prefix);
if (empty($info)) {
$info = array();
$good = $this->field('count(*) as count')->where(array('geval_goodsid' => $goods_id, 'geval_scores' => array('in', '4,5')))->find();
$info['good'] = $good['count'];
$normal = $this->field('count(*) as count')->where(array('geval_goodsid' => $goods_id, 'geval_scores' => array('in', '2,3')))->find();
$info['normal'] = $normal['count'];
$bad = $this->field('count(*) as count')->where(array('geval_goodsid' => $goods_id, 'geval_scores' => array('in', '1')))->find();
$info['bad'] = $bad['count'];
$info['all'] = $info['good'] + $info['normal'] + $info['bad'];
if (intval($info['all']) > 0) {
$info['good_percent'] = intval($info['good'] / $info['all'] * 100);
$info['normal_percent'] = intval($info['normal'] / $info['all'] * 100);
$info['bad_percent'] = intval($info['bad'] / $info['all'] * 100);
$info['good_star'] = ceil($info['good'] / $info['all'] * 5);
} else {
$info['good_percent'] = 100;
$info['normal_percent'] = 0;
$info['bad_percent'] = 0;
$info['good_star'] = 5;
}
//更新商品表好评星级和评论数
$model_goods = Model('goods');
$update = array();
$update['evaluation_good_star'] = $info['good_star'];
$update['evaluation_count'] = $info['all'];
$model_goods->editGoods($update, array('goods_id' => $goods_id));
wcache($goods_id, $info, $prefix);
}
return $info;
}
示例3: getMemberInfoByID
/**
* 取得会员详细信息(优先查询缓存)
* 如果未找到,则缓存所有字段
* @param int $member_id
* @param string $field 需要取得的缓存键值, 例如:'*','member_name,member_sex'
* @return array
*/
public function getMemberInfoByID($member_id, $fields = '*') {
$member_info = rcache($member_id, 'member', $fields);
if (empty($member_info)) {
$member_info = $this->getMemberInfo(array('member_id'=>$member_id),'*',true);
wcache($member_id, $member_info, 'member');
}
return $member_info;
}
示例4: getEvaluateStoreInfoByScID
/**
* 根据分类编号获取分类评分数据
*/
public function getEvaluateStoreInfoByScID($sc_id)
{
$prefix = 'sc_evaluate_store_info';
$info = rcache($sc_id, $prefix);
if (empty($info)) {
$model_store = Model('store');
$store_id_string = $model_store->getStoreIDString(array('sc_id' => $sc_id));
$info = $this->_getEvaluateStore(array('seval_storeid' => array('in', $store_id_string)));
wcache($sc_id, $info, $prefix);
}
return $info;
}
示例5: manageList
/**
* 圈主和管理信息
*/
protected function manageList()
{
$prefix = 'circle_managelist';
$manager_list = rcache($this->c_id, $prefix);
if (empty($manager_list)) {
$manager_list = Model()->table('circle_member')->where(array('circle_id' => $this->c_id, 'is_identity' => array('in', array(1, 2))))->select();
$manager_list = array_under_reset($manager_list, 'is_identity', 2);
$manager_list[2] = array_under_reset($manager_list[2], 'member_id', 1);
wcache($this->c_id, $manager_list, $prefix);
}
Tpl::output('creator', $manager_list[1][0]);
Tpl::output('manager_list', $manager_list[2]);
}
示例6: indexOp
/**
* 单个商品信息页
*/
public function indexOp()
{
$goods_id = intval($_GET['goods_id']);
// 商品详细信息
$model_goods = Model('goods');
$goods_detail = $model_goods->getGoodsDetail($goods_id);
$goods_info = $goods_detail['goods_info'];
if (empty($goods_info)) {
showMessage(L('goods_index_no_goods'), '', 'html', 'error');
}
// by 33hao.com
$rs = $model_goods->getGoodsList(array('goods_commonid' => $goods_info['goods_commonid']));
$count = 0;
foreach ($rs as $v) {
$count += $v['goods_salenum'];
}
$goods_info['goods_salenum'] = $count;
// 添加 end
$this->getStoreInfo($goods_info['store_id']);
Tpl::output('spec_list', $goods_detail['spec_list']);
Tpl::output('spec_image', $goods_detail['spec_image']);
Tpl::output('goods_image', $goods_detail['goods_image']);
Tpl::output('mansong_info', $goods_detail['mansong_info']);
Tpl::output('gift_array', $goods_detail['gift_array']);
// 生成缓存的键值
$hash_key = $goods_info['goods_id'];
$_cache = rcache($hash_key, 'product');
if (empty($_cache)) {
// 查询SNS中该商品的信息
$snsgoodsinfo = Model('sns_goods')->getSNSGoodsInfo(array('snsgoods_goodsid' => $goods_info['goods_id']), 'snsgoods_likenum,snsgoods_sharenum');
$data = array();
$data['likenum'] = $snsgoodsinfo['snsgoods_likenum'];
$data['sharenum'] = $snsgoodsinfo['snsgoods_sharenum'];
// 缓存商品信息
wcache($hash_key, $data, 'product');
}
$goods_info = array_merge($goods_info, $_cache);
$inform_switch = true;
// 检测商品是否下架,检查是否为店主本人
if ($goods_info['goods_state'] != 1 || $goods_info['goods_verify'] != 1 || $goods_info['store_id'] == $_SESSION['store_id']) {
$inform_switch = false;
}
Tpl::output('inform_switch', $inform_switch);
// 如果使用运费模板
if ($goods_info['transport_id'] > 0) {
// 取得三种运送方式默认运费
$model_transport = Model('transport');
$transport = $model_transport->getExtendList(array('transport_id' => $goods_info['transport_id'], 'is_default' => 1));
if (!empty($transport) && is_array($transport)) {
foreach ($transport as $v) {
$goods_info[$v['type'] . "_price"] = $v['sprice'];
}
}
}
Tpl::output('goods', $goods_info);
//v3-b11 抢购商品是否开始
$IsHaveBuy = 0;
if (!empty($_SESSION['member_id'])) {
$buyer_id = $_SESSION['member_id'];
$promotion_type = $goods_info["promotion_type"];
if ($promotion_type == 'groupbuy') {
//检测是否限购数量
$upper_limit = $goods_info["upper_limit"];
if ($upper_limit > 0) {
//查询些会员的订单中,是否已买过了
$model_order = Model('order');
//取商品列表
$order_goods_list = $model_order->getOrderGoodsList(array('goods_id' => $goods_id, 'buyer_id' => $buyer_id, 'goods_type' => 2));
if ($order_goods_list) {
//取得上次购买的活动编号(防一个商品参加多次团购活动的问题)
$promotions_id = $order_goods_list[0]["promotions_id"];
//用此编号取数据,检测是否这次活动的订单商品。
$model_groupbuy = Model('groupbuy');
$groupbuy_info = $model_groupbuy->getGroupbuyInfo(array('groupbuy_id' => $promotions_id));
if ($groupbuy_info) {
$IsHaveBuy = 1;
} else {
$IsHaveBuy = 0;
}
}
}
}
}
Tpl::output('IsHaveBuy', $IsHaveBuy);
//end
$model_plate = Model('store_plate');
// 顶部关联版式
if ($goods_info['plateid_top'] > 0) {
$plate_top = $model_plate->getStorePlateInfoByID($goods_info['plateid_top']);
Tpl::output('plate_top', $plate_top);
}
// 底部关联版式
if ($goods_info['plateid_bottom'] > 0) {
$plate_bottom = $model_plate->getStorePlateInfoByID($goods_info['plateid_bottom']);
Tpl::output('plate_bottom', $plate_bottom);
}
Tpl::output('store_id', $goods_info['store_id']);
//.........这里部分代码省略.........
示例7: getHotCollectList
/**
* 获取商品收藏排行
*
* @param int $store_id 店铺编号
* @param int $limit 数量
* @return array 商品信息
*/
public function getHotCollectList($store_id, $limit = 5)
{
$prefix = 'store_collect_sales_list_' . $limit;
$hot_collect_list = rcache($store_id, $prefix);
if (empty($hot_collect_list)) {
$model_goods = Model('goods');
$hot_collect_list = $model_goods->getGoodsOnlineList(array('store_id' => $store_id), '*', 0, 'goods_collect desc', $limit);
wcache($store_id, $hot_collect_list, $prefix);
}
return $hot_collect_list;
}
示例8: _wGoodsBundlingCache
/**
* 写入商品优惠套装缓存
* @param int $goods_id
* @param array $array
* @return boolean
*/
private function _wGoodsBundlingCache($goods_id, $array)
{
return wcache($goods_id, $array, 'goods_bundling');
}
示例9: getEvaluateStoreInfoByScID
/**
* 根据分类编号获取分类评分数据
*/
public function getEvaluateStoreInfoByScID($sc_id)
{
$prefix = 'sc_evaluate_store_info';
$info = rcache($sc_id, $prefix);
if (empty($info)) {
$model_store = Model('store');
$store_id_string = $model_store->getStoreIDString(array('sc_id' => $sc_id));
$info = $this->_getEvaluateStore(array('seval_storeid' => array('in', $store_id_string)));
$cache = array();
$cache['evaluate_store_info'] = serialize($info);
wcache($sc_id, $cache, $prefix, 60 * 24);
} else {
$info = unserialize($info['evaluate_store_info']);
}
return $info;
}
示例10: editbrand
public function editbrand($update, $condition)
{
//清空缓存
$store_list = $this->getStoreList($condition);
foreach ($store_list as $value) {
wcache($value['brand_id'], array(), 'store_info');
}
return $this->where($condition)->update($update);
}
示例11: get_member_detail_info
/**
* 用户详细信息
*/
protected function get_member_detail_info($member_info)
{
//生成缓存的键值
$member_id = $member_info['member_id'];
if ($member_id <= 0) {
return null;
}
//写入缓存的数据
$cachekey_arr = array('member_name', 'store_id', 'member_avatar', 'member_qq', 'member_email', 'member_msn', 'member_ww', 'member_points', 'available_predeposit', 'member_snsvisitnum', 'credit_arr', 'fan_count', 'attention_count');
//先查找$member_id缓存
if ($_cache = rcache($member_id, 'sns_member')) {
foreach ($_cache as $k => $v) {
$member_info[$k] = $v;
}
} else {
$model = Model();
//粉丝数
$fan_count = $model->table('sns_friend')->where(array('friend_tomid' => $member_id))->count();
$member_info['fan_count'] = $fan_count;
//关注数
$attention_count = $model->table('sns_friend')->where(array('friend_frommid' => $member_id))->count();
$member_info['attention_count'] = $attention_count;
//兴趣标签
$mtag_list = $model->table('sns_membertag,sns_mtagmember')->field('mtag_name')->on('sns_membertag.mtag_id = sns_mtagmember.mtag_id')->join('inner')->where(array('sns_mtagmember.member_id' => $member_id))->select();
$tagname_array = array();
if (!empty($mtag_list)) {
foreach ($mtag_list as $val) {
$tagname_array[] = $val['mtag_name'];
}
}
$member_info['tagname'] = $tagname_array;
wcache($member_id, $member_info, 'sns_member');
}
return $member_info;
}
示例12: browseOp
/**
* 将缓存中的浏览记录存入数据库中,并删除30天前的浏览历史
*/
public function browseOp()
{
$model = Model('goods_browse');
//将cache中的记录存入数据库
if (C('cache.type') != 'file') {
//如果浏览记录已经存入了缓存中,则将其整理到数据库中
//上次更新缓存的时间
$latest_record = $model->getGoodsbrowseOne(array(), '', 'browsetime desc');
$starttime = ($t = intval($latest_record['browsetime'])) ? $t : 0;
$monthago = strtotime(date('Y-m-d', time())) - 86400 * 30;
$model_member = Model('member');
//查询会员信息总条数
$countnum = $model_member->getMemberCount(array());
$eachnum = 100;
for ($i = 0; $i < $countnum; $i += $eachnum) {
//每次查询100条
$member_list = $model_member->getMemberList(array(), '*', 0, 'member_id asc', "{$i},{$eachnum}");
foreach ((array) $member_list as $k => $v) {
$insert_arr = array();
$goodsid_arr = array();
//生成缓存的键值
$hash_key = $v['member_id'];
$browse_goodsid = rcache($hash_key, 'goodsbrowse', 'goodsid');
if ($browse_goodsid) {
//删除缓存中多余的浏览历史记录,仅保留最近的30条浏览历史,先取出最近30条浏览历史的商品ID
$cachegoodsid_arr = $browse_goodsid['goodsid'] ? unserialize($browse_goodsid['goodsid']) : array();
unset($browse_goodsid['goodsid']);
if ($cachegoodsid_arr) {
$cachegoodsid_arr = array_slice($cachegoodsid_arr, -30, 30, true);
}
//处理存入数据库的浏览历史缓存信息
$_cache = rcache($hash_key, 'goodsbrowse');
foreach ((array) $_cache as $c_k => $c_v) {
$c_v = unserialize($c_v);
if ($c_v['browsetime'] >= $starttime) {
//如果 缓存中的数据未更新到数据库中(即添加时间大于上次更新到数据库中的数据时间)则将数据更新到数据库中
$tmp_arr = array();
$tmp_arr['goods_id'] = $c_v['goods_id'];
$tmp_arr['member_id'] = $v['member_id'];
$tmp_arr['browsetime'] = $c_v['browsetime'];
$tmp_arr['gc_id'] = $c_v['gc_id'];
$tmp_arr['gc_id_1'] = $c_v['gc_id_1'];
$tmp_arr['gc_id_2'] = $c_v['gc_id_2'];
$tmp_arr['gc_id_3'] = $c_v['gc_id_3'];
$insert_arr[] = $tmp_arr;
$goodsid_arr[] = $c_v['goods_id'];
}
//除了最近的30条浏览历史之外多余的浏览历史记录或者30天之前的浏览历史从缓存中删除
if (!in_array($c_v['goods_id'], $cachegoodsid_arr) || $c_v['browsetime'] < $monthago) {
unset($_cache[$c_k]);
}
}
//删除已经存在的该商品浏览记录
if ($goodsid_arr) {
$model->delGoodsbrowse(array('member_id' => $v['member_id'], 'goods_id' => array('in', $goodsid_arr)));
}
//将缓存中的浏览历史存入数据库
if ($insert_arr) {
$model->addGoodsbrowseAll($insert_arr);
}
//重新赋值浏览历史缓存
dcache($hash_key, 'goodsbrowse');
$_cache['goodsid'] = serialize($cachegoodsid_arr);
wcache($hash_key, $_cache, 'goodsbrowse');
}
}
}
}
//删除30天前的浏览历史
$model->delGoodsbrowse(array('browsetime' => array('lt', $monthago)));
}
示例13: _wGoodsMansongCache
/**
* 写入商品满即送缓存
* @param int $store_id
* @param array $mansong_info
* @return boolean
*/
private function _wGoodsMansongCache($store_id, $mansong_info)
{
return wcache($store_id, $mansong_info, 'goods_mansong');
}
示例14: delPointCart
/**
* 删除特定条件礼品购物车信息
* @param mixed $pc_id 删除记录编号
*/
public function delPointCart($where, $member_id = 0){
$result = $this->table('points_cart')->where($where)->delete();
//清除相关缓存
if ($result && $member_id > 0){
wcache($member_id, array('pointcart_count' => null), 'm_pointcart');
}
return $result;
}
示例15: getGoodsCountByStoreArray
/**
* 获取店铺商品数
*
* @param array $store_array 店铺数组
* @return array $store_array 包含商品数goods_count的店铺数组
*/
public function getGoodsCountByStoreArray($store_array)
{
$store_array_new = array();
$model = Model();
$no_cache_store = '';
foreach ($store_array as $value) {
$goods_count = rcache($value['store_id'], 'store_goods_count');
if (!empty($goods_count) && $goods_count !== FALSE) {
//有缓存的直接赋值
$value['goods_count'] = $goods_count;
} else {
//没有缓存记录store_id,统计从数据库读取
$no_cache_store .= $value['store_id'] . ',';
$value['goods_count'] = '0';
}
$store_array_new[$value['store_id']] = $value;
}
if (!empty($no_cache_store)) {
//从数据库读取店铺商品数赋值并缓存
$no_cache_store = rtrim($no_cache_store, ',');
$condition = array();
$condition['goods_state'] = '1';
$condition['store_id'] = array('in', $no_cache_store);
$goods_count_array = $model->table('goods')->field('store_id,count(*) as goods_count')->where($condition)->group('store_id')->select();
if (!empty($goods_count_array)) {
foreach ($goods_count_array as $value) {
$store_array_new[$value['store_id']]['goods_count'] = $value['goods_count'];
wcache($value['store_id'], $value['goods_count'], 'store_goods_count');
}
}
}
return $store_array_new;
}