နားလည်ထားရမယ့် အချက်
Redis Pub/Sub က publishers ကို subscribers များနှင့် channel ဖြင့်ချိတ်ပေးပါတယ်။ Message history၊ acknowledgement၊ replay မရှိဘဲ subscriber disconnect ဖြစ်နေချိန် message ပျောက်ပါတယ်။ ဒါကြောင့် presence၊ live UI hint နဲ့ disposable notifications အတွက်ကောင်းပြီး reliable jobs/audit events အတွက် Streams သုံးသင့်ပါတယ်။
လက်တွေ့ scenario နဲ့ ချိတ်ကြည့်မယ်
Tutorial publish ဖြစ်တဲ့အခါ `tutorial:published` channel သို့ small event ID ပို့ပြီး websocket gateways က subscribe လုပ်မယ်။ Gateway က event ID ဖြင့် durable API data ကိုပြန်ဖတ်မယ်။ Subscriber connection ကို command connection နဲ့သီးခြားထားမယ်။
အတူတူ စမ်းရေးကြည့်မယ်
SUBSCRIBE tutorial:published
PSUBSCRIBE tutorial:*
PUBLISH tutorial:published '{"tutorialId":42,"version":3}'
PUBSUB NUMSUB tutorial:publishedOnline subscribers များ event ချက်ချင်းရပြီး offline subscriber အတွက် replay မရှိပါ။၅ မိနစ် စမ်းကြည့်
Presence indicator နဲ့ payment event နှစ်ခုထဲ ဘယ်ဟာ Pub/Sub သုံးသင့်ကြောင်း reason ရေးပါ။
သတိလေးတစ်ချက်
Pub/Sub message ရောက်တာကို job completed အဖြစ်မယူဆပါနှင့်—acknowledgement မရှိပါ။
Redis — Pub/Sub — Redis