hyperf-chat/app/Command/TestCommand.php

182 lines
5.5 KiB
PHP
Raw Normal View History

2021-05-20 16:53:34 +08:00
<?php
declare(strict_types=1);
namespace App\Command;
2021-05-20 22:23:48 +08:00
use App\Cache\FriendRemark;
use App\Cache\LastMessage;
2021-05-20 16:53:34 +08:00
use App\Cache\Repository\HashRedis;
use App\Cache\Repository\ListRedis;
use App\Cache\Repository\LockRedis;
2021-05-21 22:56:42 +08:00
use App\Cache\Repository\HashGroupRedis;
use App\Cache\Repository\SetGroupRedis;
2021-05-20 16:53:34 +08:00
use App\Cache\Repository\SetRedis;
use App\Cache\Repository\StreamRedis;
use App\Cache\Repository\StringRedis;
use App\Cache\Repository\ZSetRedis;
2021-05-22 14:47:46 +08:00
use App\Cache\SocketFdBindUser;
2021-05-21 22:56:42 +08:00
use App\Cache\SocketRoom;
2021-05-22 14:47:46 +08:00
use App\Cache\SocketUserBindFds;
2021-05-20 22:23:48 +08:00
use App\Cache\UnreadTalk;
2021-07-01 23:10:18 +08:00
use App\Constants\FileMediaType;
2021-06-29 17:30:43 +08:00
use App\Model\Group\Group;
use App\Model\Group\GroupMember;
2021-07-05 21:52:44 +08:00
use App\Model\TalkList;
2021-05-20 22:23:48 +08:00
use App\Service\TalkService;
2021-05-20 16:53:34 +08:00
use Hyperf\Command\Command as HyperfCommand;
use Hyperf\Command\Annotation\Command;
2021-07-05 21:52:44 +08:00
use Hyperf\DbConnection\Db;
2021-06-30 19:27:49 +08:00
use League\Flysystem\Filesystem;
2021-05-20 16:53:34 +08:00
use Psr\Container\ContainerInterface;
/**
* @Command
*/
class TestCommand extends HyperfCommand
{
/**
* @var ContainerInterface
*/
protected $container;
public function __construct(ContainerInterface $container)
{
$this->container = $container;
parent::__construct('test:command');
}
public function configure()
{
parent::configure();
$this->setDescription('Hyperf Demo Command');
}
public function handle()
{
2021-06-04 19:55:20 +08:00
//$lock = LockRedis::getInstance();
2021-05-20 16:53:34 +08:00
//var_dump($lock->delete('ttt'));
2021-05-25 18:20:55 +08:00
//var_dump($lock->lock('ttt', 180, 5));
2021-05-20 16:53:34 +08:00
//$string = StringRedis::getInstance();
//var_dump($string->set('yuandong', 'dong', 30));
//var_dump($string->ttl('yuandong'));
//var_dump($string->isExist('yuandong'));
2021-05-21 22:56:42 +08:00
//$hash = HashRedis::getInstance();
2021-05-20 16:53:34 +08:00
//for ($i = 0; $i < 10; $i++) {
// $hash->add('user:' . $i, (string)rand(0, 100));
//}
//var_dump($hash->count());
//var_dump($hash->all());
//var_dump($hash->isMember('user:1'));
//var_dump($hash->rem('user:3'));
2021-05-21 17:43:41 +08:00
//var_dump($hash->get('user:6','user:7'));
2021-05-20 16:53:34 +08:00
//$hash->incr('user:6',11);
//var_dump($hash->get('user:6'));
//$list = ListRedis::getInstance();
//$list->push('1','2','3','4','5');
//var_dump($list->all());
//var_dump($list->clear());
//var_dump($list->count());
//$set = SetRedis::getInstance();
//$set->add('user1','user:2','user:3');
//var_dump($set->all());
//var_dump($set->count());
//var_dump($set->isMember('user:3'));
//var_dump($set->randMember(2));
//$zset = ZSetRedis::getInstance();
2021-05-21 17:43:41 +08:00
//for ($i = 1; $i < 100; $i++) {
// $zset->add('user:' . $i, $i);
2021-05-20 16:53:34 +08:00
//}
2021-05-21 17:43:41 +08:00
//$zset->delete();
2021-05-20 16:53:34 +08:00
//var_dump($zset->count());
2021-05-21 17:43:41 +08:00
//var_dump($zset->rank(2,10));
2021-05-20 16:53:34 +08:00
//var_dump($zset->getMemberScore('user:2'));
//var_dump($zset->getMemberRank('user:2'));
//var_dump($zset->rank());
//var_dump($zset->range('20','60'));
//$stream = StreamRedis::getInstance();
//var_dump($stream->info());
//for ($i = 0; $i < 10; $i++) {
// $stream->add([
// 'user_id' => $i,
// 'time' => time()
// ]);
//}
//
//$stream->run(function (string $id, array $data): bool {
// echo PHP_EOL . " 消息ID: {$id} , 任务数据: " . json_encode($data);
//
// return true;
//}, 'default', 'default');
2021-05-20 22:23:48 +08:00
//FriendRemark::getInstance()->reload();
//LastMessage::getInstance()->save(2, 1, 3, [
// 'created_at' => date('Y-m-d H:i:s'),
// 'content' => '那三级卡那那可是那那会计师哪安顺科技那发'
//]);
//var_dump(LastMessage::getInstance()->read(3, 6, 3));
//var_dump(UnreadTalk::getInstance()->read(1, 2));
//UnreadTalk::getInstance()->save(1, 2);
//$talk = UnreadTalk::getInstance();
//for ($i = 1; $i < 10; $i++) {
// for ($j = 1; $j < 10; $j++) {
// $talk->increment($i, $j);
// }
//}
//$model = new TalkService();
//$model->talks(2054);
2021-05-21 17:43:41 +08:00
//var_dump(FriendRemark::getInstance()->read(2054,2055));
2021-05-21 22:56:42 +08:00
//$socketRoom = SocketRoom::getInstance();
//$socketRoom->addRoomMember('');
//$keys = redis()->keys('rds-set*');
//foreach ($keys as $key) {
// redis()->del($keys);
//}
2021-05-22 14:47:46 +08:00
//SocketFdBindUser::getInstance()->bind(1, 2054);
//SocketUserBindFds::getInstance()->bind(1, 2054);
2021-06-04 19:55:20 +08:00
2021-06-29 17:30:43 +08:00
//$model1 = SocketUserBindFds::getInstance();
//$model2 = FriendRemark::getInstance();
//
//var_dump($model1 === SocketUserBindFds::getInstance());
//var_dump($model2 === FriendRemark::getInstance());
//
//var_dump(SocketUserBindFds::getInstance());
//var_dump(FriendRemark::getInstance());
2021-06-04 19:55:20 +08:00
//SocketUserBindFds::getInstance();
//SocketUserBindFds::getInstance();
//SocketRoom::getInstance();
//FriendRemark::getInstance();
//SocketUserBindFds::getInstance();
//SocketRoom::getInstance();
//FriendRemark::getInstance();
//var_dump(SocketUserBindFds::getInstance());
//var_dump(SocketRoom::getInstance());
//var_dump(FriendRemark::getInstance());
//
//var_dump('------');
//var_dump(SocketUserBindFds::getInstance());
//var_dump(SocketRoom::getInstance());
//var_dump(FriendRemark::getInstance());
2021-06-29 17:30:43 +08:00
//var_dump(Group::isManager(2054,116));
2021-05-20 16:53:34 +08:00
}
}