123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113 |
- <?php
- namespace app\index\controller;
- use think\Db;
- use Redis;
- class Test
- {
-
- public function showredis(){
- $list = Db::name('user')->order('id desc')->column('id');
- foreach($list as $key => $id){
- dump($id.':'.redis_matching_get($id));
- echo '<br/>';
- }
- exit;
- }
-
- public function clearredis(){
- $list = Db::name('user')->order('id desc')->column('id');
- foreach($list as $key => $id){
- $a = redis_matching_set($id,0);
- }
- exit;
- }
- public function test1(){
-
- $buffer1 = 'abcdefghijklmn';
- $buffer2 = '{"type":"say", "content":"hello", "content":"hello", "content":"hello", "content":"hello", "content":"hello", "content":"hello", "content":"hello", "content":"hello", "content":"hello", "content":"hello", "content":"hello", "content":"hello", "content":"hello", "content":"hello", "content":"hello", "content":"hello", "content":"hello", "content":"hello", "content":"hello", "content":"hello", "content":"hello", "content":"hello", "content":"hello", "content":"hello", "content":"hello", "content":"hello", "content":"hello", "content":"hello", "content":"hello", "content":"hello", "content":"hello", "content":"hello", "content":"hello", "content":"hello", "content":"hello"}'."";
- $buffer2 = 'abcdefghijklmn'."\n";
- $client = stream_socket_client('tcp://1.14.197.70:2349');
-
- fwrite($client, $buffer2);
- }
-
- public function show_livebc(){
- $party_id = input('party_id');
- if(empty($party_id)){
- $this->error();
- }
- $redis = new Redis();
- $redisconfig = config("redis");
- $redis->connect($redisconfig["host"], $redisconfig["port"]);
- $a = $redis->get("livebc_".$party_id);
- dump($a);
- }
-
- public function show_livebc_jewel(){
- $party_id = input('party_id');
- if(empty($party_id)){
- $this->error();
- }
- $redis = new Redis();
- $redisconfig = config("redis");
- $redis->connect($redisconfig["host"], $redisconfig["port"]);
- $userModel = new \app\common\model\User();
-
- $num = 3;
-
- $getweek = $redis->zRevRange("livebc_jewel_to_".$party_id,0,-1,true);
- $getweek2 = $redis->zRevRange("livebc_jewel_get_".$party_id,0,0,true);
- $userList = $userModel->rankList($getweek);
- $userList2 = $userModel->rankList($getweek2);
- dump($getweek);
- dump($getweek2);
- dump($userList);
- dump($userList2);
- $avatarArr = [];
- if($userList) {
- foreach($userList as $k => $v) {
- $v["jewel"] > 0 && $avatarArr[] = $v["avatar"];
- }
-
- $redis->hSet("user_jewel_top3",$party_id,json_encode($avatarArr));
-
- }
- dump($avatarArr);
- }
-
- public function clear(){
- $party_id = input('party_id');
- if(empty($party_id)){
- $this->error();
- }
-
- $redis = new Redis();
- $redisconfig = config("redis");
- $redis->connect($redisconfig["host"], $redisconfig["port"]);
- $redis->del('livebc_jewel_to_' . $party_id);
- $redis->del('livebc_jewel_get_' . $party_id);
- $redis->hDel("user_jewel_top3",$party_id);
- }
- }
|