$redis->hSet('product:123', 'like_num ', 5); // 添加 id为123的商品 like_num 为5
$redis->hIncrBy('product:123', 'like_num ', 1); // 添加 id为123的商品like_num +1
$redis->hGetAll('product:123'); // 获取id为123的商品相关信息
array('like_num '=> 1)
$redis->hSet('user:100000', 'follow ', 5); // 添加uid为10000的用户follow 为5
$redis->hIncrBy('user:100000', 'follow ', 1); // 更新uid为10000的用户follow +1
$redis->hGetAll('user:100000'); // 获取uid为10000的用户
array('like_num '=> 1)
$redis->zAdd('user:1000:follow', 1463557212, '1001');
#uid为1000用户关注uid为1001 , score值设定时间戳1463557212
$redis->zAdd('user:1000:follow', 1463557333, '1002');
$redis->zAdd('user:2000:follow', 1463577568, '1001');
$redis->zAdd('user:2000:follow', 1463896964, '1003');
#uid为2000用户关注1001和1003用户 , score值设定时间戳
$redis->zInter('com_fllow:1000:2000', array('user:1000:follow', 'user:2000:follow'));
#对集合'user:1000:follow'和'user:2000:follow'取交集'com_fllow:1000:2000'
#获得共同关注的uid
$redis->zRange('com_fllow:1000:2000',0,-1); // 获取全部集合元素
#array('10001','10002')
#获取5秒内操作记录
$res = $redis->zRangeByScore('user:1000:comment', time() - 5, time());
#判断5秒内不能评论
if (!$res) {
$redis->zAdd('user:1000:comment', time(), '评论内容');
} else {
echo '5秒之内不能评论';
}
#5秒内评论不得超过2次
if($redis->zRangeByScore('user:1000:comment',time()-5 ,time())==1)
echo '5秒之内不能评论2次';
#5秒内评论不得少于2次
if(count($redis->zRangeByScore('user:1000:comment',time()-5 ,time()))<2)
echo '5秒之内不能评论2次';
$redis->zAdd('user:2000:feed:topic', time(), '13');
//score 为timestamp uid为2000的用户关注tid为13的topic
$redis->expire('user:2000:feed:topic',24*60*60);
#关注有效期为24小时
# ttl 30天之内按秒数计算 30天之外以timestamp为准
$redis->zAdd('user:1000:product:like', time(), '3002');
$redis->zAdd('user:1000:product:like', time(), '3001');
$redis->zAdd('user:1000:product:like', time(), '3004');
$redis->zAdd('user:1000:product:like', time(), '3003');
$redis->zRange('user:1000:product:like', 0, -1,true);
#默认喜欢时间升序序排列
#
Array(
[3002] => 1463565179
[3001] => 1463565189
[3004] => 1463565199
[3003] => 1463565209
)
$redis->zRevRange('user:1000:product:like', 0, -1,true);
#以喜欢时间降序排列
#
Array
(
[3003] => 1463565424
[3004] => 1463565414
[3001] => 1463565404
[3002] => 1463565394
)
$redis->lPush('user:1000:product:like', '3002');
$redis->lPush('user:1000:product:like', '3001');
$redis->lPush('user:1000:product:like', '3004');
$redis->lPush('user:1000:product:like', '3003');
$redis->lRange('user:1000:product:like', 0, -1);
Array
(
[0] => 3003
[1] => 3004
[2] => 3001
[3] => 3002
)
$redis->hSet('user:1000:message:notice', 'system', 1);
#设置1条未读系统消息
$redis->hIncrBy('user:1000:message:notice', 'system', 1);
#未读系统消息+1
$redis->hSet('user:1000:message:notice', 'comment', 1);
#设置1条未读评论
$redis->hIncrBy('user:1000:message:notice', 'comment', 1);
#未读评论+1
$redis->hGetAll('user:1000:message:notice');
#查看所有消息通知数量
Array
(
[system] => 2
[comment] => 2
)
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有