Thuta Learning
ရှာဖွေရန်
Redis
ProjectsData & Databasesbeginner

Project 4 — Leaderboard နှင့် Notifications

ဒီခန်းပြီးရင် ဘာတတ်သွားမလဲ

  • Project 4 — Leaderboard နှင့် Notifications concept ကို နားလည်ရှင်းပြနိုင်ရန်
  • နမူနာ Redis command/code ကို ကိုယ်တိုင် run ပြီး output စစ်နိုင်ရန်
  • Tutorial Platform project နှင့် production scenario တွင် မှန်ကန်စွာအသုံးချနိုင်ရန်

နားလည်ထားရမယ့် အချက်

Leaderboard score update ကို durable completion event မှ derive လုပ်ပြီး sorted set သို့ idempotently apply ရပါတယ်။ Pub/Sub က UI refresh hint သာဖြစ်ပြီး client reconnect လျှင် API မှ canonical leaderboard ပြန်ဖတ်ရပါတယ်။ Season keys၊ tie policy၊ privacy နဲ့ rebuild tooling က project requirement ပါ။

လက်တွေ့ scenario နဲ့ ချိတ်ကြည့်မယ်

PostgreSQL completion unique ID ကို processed set/idempotency table နဲ့စစ်ပြီး weekly sorted set score တိုးမယ်။ Rank changed event ကို Pub/Sub ပို့မယ်။ API က top 100 နဲ့ requesting user neighborhood ပြန်ပေးပြီး admin rebuild command က DB events မှ key အသစ်တည်ဆောက်ကာ rename/switch လုပ်မယ်။

အတူတူ စမ်းရေးကြည့်မယ်

shell
SADD processed:completion:2026-W35 completion:9001
ZINCRBY leaderboard:2026-W35 1 user:42
ZREVRANGE leaderboard:2026-W35 0 99 WITHSCORES
ZREVRANK leaderboard:2026-W35 user:42
PUBLISH leaderboard:changed '{"season":"2026-W35","userId":42}'
You should see
Idempotent weekly score၊ rank API နဲ့ live refresh signal ရမည်။

၅ မိနစ် စမ်းကြည့်

Top 3 ties၊ deleted user၊ season rollover နဲ့ rebuild-during-traffic tests ရေးပါ။

သတိလေးတစ်ချက်

`SADD` နဲ့ `ZINCRBY` ကိုသီးခြား non-atomic လုပ်ရင် crash အချိန် event marked-but-not-scored ဖြစ်နိုင်ပါတယ်။ Script/transaction သုံးပါ။

Redis — Sorted SetsRedis

ဒီနေရာမှာ လူအများမှားတတ်တယ်

  • `SADD` နဲ့ `ZINCRBY` ကိုသီးခြား non-atomic လုပ်ရင် crash အချိန် event marked-but-not-scored ဖြစ်နိုင်ပါတယ်။ Script/transaction သုံးပါ။
  • နမူနာ command ကို production Redis ပေါ် တိုက်ရိုက်မစမ်းဘဲ local/test instance နဲ့ recoverable data ပေါ်တွင် အရင်အတည်ပြုပါ။

လေ့ကျင့်ခန်း

Top 3 ties၊ deleted user၊ season rollover နဲ့ rebuild-during-traffic tests ရေးပါ။

You'll know it worked when: Idempotent weekly score၊ rank API နဲ့ live refresh signal ရမည်။

Project 4 — Leaderboard နှင့် Notifications | Thuta Learning