0
1

More than 5 years have passed since last update.

MacにRedis入れてSUB/PUBとかを試す

Posted at

Laravel EchoでRedis(SUB/PUB)使うのでおさらい。

インストール

brew install redis

Redisサーバの起動

redis-server

終了はctr + cで。

Redisクライアントの利用

別のコンソールで、

redis-cli
127.0.0.1:6379>

Key-Valueの登録・確認

いちおう。どんなkeyがあるかはKeysで確認。

set name hoge
get name

Keys *

SUBSCRIBE/PUBLISH

コンソール1で

redis-cli
>SUBSCRIBE hoge
1) "subscribe"
2) "hoge"
3) (integer) 1

hogeというチャネルを購読。

コンソール2で、

redis-cli
>PUBLISH hoge "hello world!"

hogeというチェネルに発行。

コンソール1に、

1) "message"
2) "hoge"
3) "hello world!"

発行したものが届く。

簡単ですが以上です。

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1