商品每日每週每月排序redis
//例項化鏈結redis
$redis = new redis();
$redis->connect(『127.0.0.1』, 6379);
//設定時區
date_default_timezone_set(『asia/shanghai』);
//設定每天資訊
$day = mktime(23, 59, 59, date(「m」), date(「d」), date(「y」));
//$redis->lpush(『goods_day』, $id);
//list lpush 可以包含相同的值, set sadd值只能是唯一
$redis->sadd(『goods_day』, $id);
//有效時間
$redis->expireat(『goods_day』, $day);
//每次載入加1
katex parse error: expected group after '_' at position 29: …goods_day_score_̲'.id);
//有效時間
katex parse error: expected group after '_' at position 33: …goods_day_score_̲'.id, $day);
//新增商品資訊只能存字串所以需要 json
katex parse error: expected group after '_' at position 27: …'goods_day_data_̲'.id, json_encode($goods));
//有效時間
katex parse error: expected group after '_' at position 32: …'goods_day_data_̲'.id, $day);
//設定每週資訊
w ee
k=mk
time
(23,59
,59,d
ate(
"m")
,dat
e("d
")−d
ate(
"w")
+7,d
ate(
"y")
);//
week = mktime(23,59,59,date("m"),date("d")-date("w")+7,date("y")); //
week=m
ktim
e(23
,59,
59,d
ate(
"m")
,dat
e("d
")−d
ate(
"w")
+7,d
ate(
"y")
);//
redis->lpush(『goods_week』, $id);
//list lpush 可以包含相同的值, set sadd值只能是唯一
$redis->sadd(『goods_week』, $id);
$redis->expireat(『goods_week』, $week);
/加一/
katex parse error: expected group after '_' at position 30: …oods_week_score_̲'.id);
katex parse error: expected group after '_' at position 34: …oods_week_score_̲'.id, $week);
katex parse error: expected group after '_' at position 28: …goods_week_data_̲'.id, json_encode($wall*****));
katex parse error: expected group after '_' at position 33: …goods_week_data_̲'.id, $week);
//進行讀取資料
//排序字段
$sort[『by』] = 『goods_week_score_』;
//分頁
s or
t[′l
imit
′]=a
rray
((
sort['limit'] = array((
sort[′
limi
t′]=
arra
y((pindex - 1) * $psize, $psize);
//排序方法
$sort[『sort』] = 『desc』;
//獲取資料內容
$sort[『get』] = 'goods_week_data_』;
//獲取資料
$res = red
is
−>so
rt(′
good
swee
k′
,redis->sort('goods_week',
redis−
>so
rt(′
good
swe
ek′,
sort);
foreach(katex parse error: expected 'eof', got '&' at position 8: res as &̲k)
//獲取資訊
return $res;
獲取每週每月開始結束日期
獲取指定日期所在周的週日日期 週日為開始,週六為結束 param date 指定日期的localdate格式資料 return public static date getstartdayofweek temporalaccessor date 獲取指定日期所在周的週六日期 週日為開始,週六為結束 ...
獲得每日,每週,每月的0點和24點的時間戳
獲得當天0點時間 public static int gettimesmorning 獲得當天24點時間 public static int gettimesnight 獲得本周一0點時間 public static int gettimesweekmorning 獲得本週日24點時間 public...
Mysql查詢每天 每週 每月 每年的資料
查詢每天的資料 select count 1 as total,date format create time,y m d as time from op endor info group by date format create time,y m d 查詢每週的資料 select count 1...