Beispiel #1
0
 public static function hadCommented($userId, $orderId, $goodsId)
 {
     $ck = Cache::CK_GOODS_HAD_COMMENT . $userId . ':' . $orderId . ':' . $goodsId;
     $ret = Cache::get($ck);
     if ($ret === false) {
         $ret = DB::getDB()->fetchCount('g_goods_comment', array('user_id', 'goods_id', 'order_id'), array($userId, $goodsId, $orderId), array('and', 'and'));
         if ($ret !== false) {
             Cache::setex($ck, Cache::CK_GOODS_HAD_COMMENT_EXPIRE, (string) $ret);
         }
     }
     return (int) $ret > 0;
 }
Beispiel #2
0
 public static function hadLiked($userId, $commentId)
 {
     $ck = Cache::CK_GOODS_COMMENT_HAD_LIKE . $commentId . ':' . $userId;
     $ret = Cache::get($ck);
     if ($ret === false) {
         $ret = DB::getDB()->fetchCount('g_goods_comment_like', array('comment_id', 'user_id'), array($commentId, $userId), array('and'));
         if ($ret !== false) {
             Cache::setex($ck, Cache::CK_GOODS_COMMENT_HAD_LIKE_EXPIRE, (string) $ret);
         }
     }
     return (int) $ret > 0;
 }
Beispiel #3
0
 public static function findSomeCouponsByIds($couponIds)
 {
     if (empty($couponIds)) {
         return array();
     }
     ksort($couponIds, SORT_NUMERIC);
     $idSet = implode(',', $couponIds);
     $ck = Cache::CK_COUPON_CFG_LIST_INFO . $idSet;
     $ret = Cache::get($ck);
     if ($ret !== false) {
         $ret = json_decode($ret, true);
     } else {
         $sql = "select * from m_coupon_cfg where id in ({$idSet})";
         $ret = DB::getDB()->rawQuery($sql);
         if ($ret !== false) {
             Cache::setex($ck, json_encode($ret), Cache::CK_COUPON_CFG_INFO_LIST_EXPIRE);
         }
     }
     return $ret === false ? array() : $ret;
 }
Beispiel #4
0
 private static function onUpdateData($goodsId)
 {
     Cache::del(Cache::CK_GOODS_SKU . $goodsId);
 }
Beispiel #5
0
 private static function onUpdateData($userId)
 {
     Cache::del(Cache::CK_USER_INFO_FOR_ID . $userId);
     $userInfo = self::findUserById($userId, 'w');
     if (!empty($userInfo['phone'])) {
         Cache::del(Cache::CK_USER_INFO_FOR_PHONE . $userInfo['phone']);
         self::findUserByPhone($userInfo['phone'], 'w');
     }
 }