总结:线上严禁使用redis的keys命令 keys checkvariantprefix:*
redis-cli -h host -p port -a password
redis-cli
//redis类型介绍 $key = 'Kaijang:lottery:frequency:simplehtml:' . $lotteryType; //字符串 //添加有效期时间 redisSet Redis::getInstance()->redisSet($key, json_encode($data), 60*10); //命令将 key 中储存的数字值增一 Redis::getInstance()->redisIncre($redisKey); //获取数据 redisGet $lotterylRedis = Redis::getInstance()->redisGet($key); //有序集合 //添加 自增1redisZincrby 小于次数,就增加金豆,并且自增1 Redis::getInstance()->redisZincrby($key, 1, '1234'); //获取有序集合的分数redisZscore $number = Redis::getInstance()->redisZscore($key, '1234'); //获取从0到-1到数据(全部数据)列表 $list = Redis::getInstance()->redisZRevRange($key, 0, -1);//只返回分数 $list = Redis::getInstance()->redisZRevRange($key, 0, -1, ['WITHSCORES' => true]);//返回分数和权重 //只展示显示每页数量,分页处理 $result = array_slice($list, ($pageNo - 1) * $pageCount, $pageCount); //哈希 //添加自增1 并返回分数值 $trueView = appluckycommonRedis::getInstance()->redisHincre(_REDIS_BLOG_VIEWS, $blogId); //获取指定多个是分数值 $blogIds =[706,709]; $views = Redis::getInstance()->redisHMgetNum('343_server:blog:blog_views', $blogIds); //添加设置哈希列表值 $eventRedisInfo = [ $eventId => json_encode($eventInfo), ]; Redis::getInstance()->redisHMSet($redisKey, $eventRedisInfo); //获取指定多个是哈希列表值 $basketIdArr = array_unique($basketIdArr); $redisKey = "Kaijiang:basketball:eventList"; $basketballEventRedisList = Redis::getInstance()->redisHMget($redisKey, $basketIdArr); //删除数据redisDel Redis::getInstance()->redisDel($key); //删除指定分数userId数据redisZrem Redis::getInstance()->redisZrem($key, $userId);