swooleRedis 데이터를 모니터링하는 방법은 무엇입니까?
Laravel은 swoole을 사용하여 redis를 모니터링합니다
시작하기 전에 Redis가 올바르게 설치되어 있고 정상적으로 실행되고 있는지 확인하세요.
Laravel 코드
AppEvents 디렉터리에 새 RedisTest 이벤트 생성
<?php namespace App\Events; use Illuminate\Broadcasting\Channel; use Illuminate\Queue\SerializesModels; use Illuminate\Broadcasting\PrivateChannel; use Illuminate\Broadcasting\PresenceChannel; use Illuminate\Foundation\Events\Dispatchable; use Illuminate\Broadcasting\InteractsWithSockets; use Illuminate\Contracts\Broadcasting\ShouldBroadcast; class RedisTest { use Dispatchable, InteractsWithSockets, SerializesModels; public $message; /** * Create a new event instance. * * @return void */ public function __construct($message) { $this->message = $message; } /** * Get the channels the event should broadcast on. * * @return \Illuminate\Broadcasting\Channel|array */ public function broadcastOn() { return new PrivateChannel('channel-name'); } }
AppListenersRedisTestListener 수신 이벤트 코드
<?php namespace App\Listeners; use App\Events\RedisTest; use Illuminate\Queue\InteractsWithQueue; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Support\Facades\Log; class RedisTestListener { /** * Create the event listener. * * @return void */ public function __construct() { // } /** * Handle the event. * * @param RedisTest $event * @return void */ public function handle(RedisTest $event) { $message = $event->message; Log::info('the message received from subscribed redis channel msg_0: '.$message); } }
AppProvidersEventServiceProvider 등록 이벤트/수신 관계
protected $listen = [ 'App\Events\RedisTest' => [ 'App\Listeners\RedisTestListener', ], ];
수신 명령
AppConsoleCommandsRedisSubscribe 코드는 다음과 같습니다
<?php namespace App\Console\Commands; use Illuminate\Console\Command; use swoole_redis; use Illuminate\Support\Facades\Event; use App\Events\RedisTest; class RedisSubscribe extends Command { /** * The name and signature of the console command. * * @var string */ protected $signature = 'redis:subscribe'; /** * The console command description. * * @var string */ protected $description = 'deamon process to subscribe redis broadcast'; /** * Create a new command instance. * * @return void */ public function __construct() { parent::__construct(); } /** * Execute the console command. * * @return mixed */ public function handle() { $client = new swoole_redis; $client->on('message', function (swoole_redis $client, $result) { var_dump($result); static $more = false; if (!$more and $result[0] == 'message') { echo "trigger Event RedisTest\n"; Event::fire(new RedisTest($result[2])); } }); $client->connect('127.0.0.1', 6379, function (swoole_redis $client, $result) { echo "connect\n"; $client->subscribe('msg_0'); }); } }
Laravel의 일부 코드가 완성되었습니다
== ================================
감독자 관리 과정
/ etc/supervisor/conf.d 폴더 새로운 echo.conf를 생성합니다. 코드는 다음과 같습니다
[group:echos] programs=echo-queue,echo-redis [program:echo-queue] command=php artisan queue:work directory=/home/bella/Downloads/lnmp/echo1.0/echo user=bella autorestart=true redirect_stderr=true stdout_logfile=/home/bella/Downloads/lnmp/echo1.0/echo/storage/logs/queue.log loglevel=info [program:echo-redis] command=php artisan redis:subscribe directory=/home/bella/Downloads/lnmp/echo1.0/echo user=bella autorestart=true redirect_stderr=true stdout_logfile=/home/bella/Downloads/lnmp/echo1.0/echo/storage/logs/redis.log loglevel=info
완료 후 다음 명령을 실행하여 다시 로드
supervisorctl reload
=============== ============= =====
redis 클라이언트에 들어가서 msg_0 채널에 브로드캐스트 알림을 게시하세요
publish msg_0 "Hello Bella"
laravel 디렉터리에 있는 Storagelogslaravel.log의 마지막 로그에 방송 알림, redis 청취 기능이 구현되었습니다
위 내용은 Swoole이 Redis 데이터를 모니터링하는 방법의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!

이 기사는 버그보고, 기능 제출, 코딩 및 문서 개선을 포함하여 Swoole Project에 기여하는 방법을 설명합니다. 초보자가 기여를 시작하기 위해 필요한 기술과 단계에 대해 논의하고, 압박을 찾는 방법은

기사는 사용자 정의 모듈, 상세 단계, 모범 사례 및 문제 해결과 함께 Swoole을 확장하는 것을 논의합니다. 주요 초점은 기능과 통합을 향상시키는 것입니다.

이 기사에서는 고성능 응용 프로그램을 위해 PHP에서 Swoole의 비동기 I/O 기능을 사용하는 것에 대해 설명합니다. 설치, 서버 설정 및 최적화 전략을 다룹니다. 워드 수 : 159

기사는 Swoole의 프로세스 격리 구성, 개선 된 안정성 및 보안 및 문제 해결 방법과 같은 이점에 대해 논의합니다. 문자 수 : 159

Swoole의 원자로 모델은 이벤트 중심의 비 블로킹 I/O 아키텍처를 사용하여 다양한 기술을 통해 성능을 최적화하는 고소도 시나리오를 효율적으로 관리합니다 (159 자)

기사는 PHP 프레임 워크 인 Swoole의 연결 문제 해결, 원인, 모니터링 및 예방에 대해 논의합니다.

이 기사는 Swoole의 성능 모니터링 및 최적화를위한 도구 및 모범 사례에 대해 설명하고 성능 문제를위한 문제 해결 방법에 대해 설명합니다.

초록 :이 기사에서는 부적절한 자원 관리 및 관리되지 않는 코 루틴과 같은 일반적인 원인을 강조하여 식별, 격리 및 고정을 통해 Swoole 애플리케이션의 메모리 누출 해결에 대해 설명합니다. Swoole 트래커 및 Valgrind와 같은 도구


핫 AI 도구

Undresser.AI Undress
사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover
사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool
무료로 이미지를 벗다

Clothoff.io
AI 옷 제거제

AI Hentai Generator
AI Hentai를 무료로 생성하십시오.

인기 기사

뜨거운 도구

Eclipse용 SAP NetWeaver 서버 어댑터
Eclipse를 SAP NetWeaver 애플리케이션 서버와 통합합니다.

DVWA
DVWA(Damn Vulnerable Web App)는 매우 취약한 PHP/MySQL 웹 애플리케이션입니다. 주요 목표는 보안 전문가가 법적 환경에서 자신의 기술과 도구를 테스트하고, 웹 개발자가 웹 응용 프로그램 보안 프로세스를 더 잘 이해할 수 있도록 돕고, 교사/학생이 교실 환경 웹 응용 프로그램에서 가르치고 배울 수 있도록 돕는 것입니다. 보안. DVWA의 목표는 다양한 난이도의 간단하고 간단한 인터페이스를 통해 가장 일반적인 웹 취약점 중 일부를 연습하는 것입니다. 이 소프트웨어는

SublimeText3 영어 버전
권장 사항: Win 버전, 코드 프롬프트 지원!

메모장++7.3.1
사용하기 쉬운 무료 코드 편집기

Atom Editor Mac 버전 다운로드
가장 인기 있는 오픈 소스 편집기
