<?php
$redis = new Redis();
$redis->connect('127.0.0.1', 6379);
$redis->auth('*****');
$plan_id = '1';
//$like_id = '2';
$uid = '6';
//$redis->ZADD("plan:$plan_id:liked", time(), $uid);
//$total = $redis->ZCARD("plan:$plan_id:liked");
$uids_z = $redis->ZREVRANGE("plan:$plan_id:liked", 0, -1, TRUE); //倒序取值
var_dump($uids_z);
$uids_d = $redis->ZRANGE("plan:$plan_id:liked", 0, -1, TRUE); //顺序取值
var_dump($uids_d);
//echo $redis ->get( "test");
//
//判断一个用户是否点赞了这一来哦
//$res = $redis->ZSCORE("plan:$plan_id:liked", $uid);
//var_dump($res);
//
//取消赞这样来
$redis->ZREM("plan:$plan_id:liked", $uid);
$uids_z = $redis->ZREVRANGE("plan:$plan_id:liked", 0, -1, TRUE); //倒序取值
var_dump($uids_z);
?>
PHP redis有序集合操作【点赞功能】
最新推荐文章于 2024-10-02 09:03:40 发布