Kanallar ve Keyspace Bildirimleri
Açık Pub/Sub kanalları ile Redis keyspace bildirimleri arasındaki farkı ve her birine ne zaman başvurmanız gerektiğini anlayın.
Kanallar ve Keyspace Bildirimleri, CoddyKit'te ücretsiz bir Redis Caching & Messaging (Pub/Sub, Streams) dersidir. Bu, 4 dersinin 4. dersidir. Aşağıdan dersin tamamını ücretsiz okuyabilir, sonra tarayıcıda yerleşik kod editörü ve 7/24 yapay zeka koçu ile uygulamalı olarak pratik yapabilirsin. Bu, Redis Caching & Messaging (Pub/Sub, Streams) öğrenme yolunun bir parçasıdır ve ilerlemeniz web ve CoddyKit uygulaması arasında senkronize olur. Redis Caching & Messaging (Pub/Sub, Streams) kursu toplamda 4 dersten oluşur.
Bu dersin bazı bölümleri henüz çevrilmemiş olup İngilizce olarak gösterilmektedir.
Two Ways to Get Notified
So far you have published to explicit channels with PUBLISH. Redis also offers keyspace notifications, which automatically emit events when keys change. Both deliver messages to subscribers, but the source differs.
Recap: Explicit Channels
With explicit channels, your application decides what to publish and when. The channel name is arbitrary text.
PUBLISH news.sports "Match ended 2-1"
SUBSCRIBE news.sportsWhat Are Keyspace Notifications?
Keyspace notifications let Redis itself publish an event whenever a key is modified, expired, or evicted. You subscribe to special channels to observe data changes without your app having to publish anything.
Enabling Notifications
They are off by default. Enable them with the notify-keyspace-events config flag, where letters select event classes.
Kkeyspace eventsEkeyevent eventsAall command/event typesxexpired,ggeneric,$string
CONFIG SET notify-keyspace-events KEAKeyspace vs Keyevent
There are two channel families:
- Keyspace:
__keyspace@0__:mykeytells you which event happened to a key - Keyevent:
__keyevent@0__:deltells you which keys had a given event
The @0 is the database number.
PSUBSCRIBE __keyspace@0__:*
PSUBSCRIBE __keyevent@0__:expiredSubscribing to Expirations
A common use case is reacting when a key expires, for example to clean up a session. Enable Ex and subscribe to the expired keyevent channel.
CONFIG SET notify-keyspace-events Ex
SUBSCRIBE __keyevent@0__:expiredA Practical Flow
Set a session key with a TTL. When it expires, Redis publishes to the expired channel, and your worker reacts.
SET session:abc "data" EX 30
# 30s later, subscriber receives:
# __keyevent@0__:expired -> session:abcDelivery Caveats
Keyspace notifications use Pub/Sub, so they are fire-and-forget. If no client is subscribed when the event fires, the message is lost. They are also not guaranteed for keys that expire while idle until a read or the background expiry cycle touches them.
When to Use Each
Use explicit channels when your app controls the event semantics (chat, notifications, custom events). Use keyspace notifications when you want to react to data mutations you do not directly control, like cache invalidation or expiry cleanup.
Performance Note
Enabling A (all events) on a busy server generates a high volume of messages and adds overhead. Subscribe only to the specific event classes you need.
CONFIG SET notify-keyspace-events EgxSummary So Far
Explicit channels are app-driven; keyspace notifications are Redis-driven. Both ride on the same lightweight Pub/Sub transport, so neither persists messages.
Quick Check
Pick the correct statement about keyspace notifications.
Recap
You compared explicit Pub/Sub channels with keyspace notifications, learned how to enable notifications via notify-keyspace-events, the keyspace vs keyevent channel families, and the fire-and-forget delivery caveats. Reach for keyspace notifications to react to data changes without publishing them yourself.
Sıkça Sorulan Sorular
“Kanallar ve Keyspace Bildirimleri” dersi ücretsiz mi?
Evet — “Kanallar ve Keyspace Bildirimleri” dersin tüm metni burada web'de ücretsiz olarak okunabilir. Etkileşimli olarak pratik yapmak (yerleşik kod editörü ve 7/24 yapay zeka koçu) ve Redis Caching & Messaging (Pub/Sub, Streams) kursunun geri kalanını açmak için CoddyKit PRO'ya yükselt. Redis Caching & Messaging (Pub/Sub, Streams) kursu toplamda 4 dersten oluşur.
“Kanallar ve Keyspace Bildirimleri” dersinde ne öğreneceğim?
Açık Pub/Sub kanalları ile Redis keyspace bildirimleri arasındaki farkı ve her birine ne zaman başvurmanız gerektiğini anlayın. Redis Caching & Messaging (Pub/Sub, Streams) ile uygulamalı kodu tarayıcıda doğrudan çalıştırarak pratik yaparsın ve 7/24 yapay zeka koçu dersi çalışırken sorularını yanıtlar.
Redis Caching & Messaging (Pub/Sub, Streams) öğrenmeye başlamak için deneyim gerekli mi?
Önceden deneyim gerekmez. CoddyKit'te Redis Caching & Messaging (Pub/Sub, Streams), başlangıçtan ileri seviyeye kadar yapılandırıldığı için buradan başlayabilir veya başından başlayıp kendi hızında ilerleme yapabilirsin. Bu, 4 dersinin 4. dersidir.
“Kanallar ve Keyspace Bildirimleri” dersi ne kadar sürer?
Çoğu CoddyKit dersi yaklaşık 5–10 dakika sürer. Her biri kısa ve etkileşimli olduğu için sabit ilerleme yaparsın ve web ile uygulama arasında tam olarak bıraktığın yerden devam edebilirsin.
Bu Redis Caching & Messaging (Pub/Sub, Streams) dersinde kod yazıp çalıştırabilir miyim?
Evet. Her Redis Caching & Messaging (Pub/Sub, Streams) dersi yerleşik bir kod editörü içerir, bu sayede tarayıcıda gerçek kod yazıp çalıştırabilir ve anlık yapay zeka geri bildirimi alırsın — yerel kurulum gerekli değildir.
Bu kursun tüm dersleri
- Yayınla/Abone Ol'a Giriş
- Redis Yayınla/Abone Ol Mekanizmaları
- Basit Mesajları Yayınlama
- Kanallar ve Keyspace Bildirimleri