عرض عملي: لوحة متصدرين بالمجموعات المرتّبة
في هذا الدرس 3 موضوعات
هذا الدرس مخطط له. يعرض المخطط أدناه الموضوعات التي سيغطيها، ولم يُنشر الدرس الكامل بعد.
نص الدروس والتمارين باللغة الإنجليزية، بينما تبقى واجهة الموقع وعناوين الدروس بالعربية.
في هذا الدرس
build a "top products this week" board. Prepares the data-structure selection scenarios.
تفاصيل المخطط المبدئي
خطوة بخطوة
- Create key
shop:top:week:2026-W44and record sales withZINCRBY key 1 productId. - Read the top 10 with
ZRANGE key 0 9 REV WITHSCORES. - Wrap it in a Spring
StringRedisTemplate.opsForZSet()service. - Set
EXPIREof two weeks so old boards disappear. - Planned mistake: store the board as a JSON string and rewrite it on each sale; two concurrent sales overwrite each other. Fix:
ZINCRBY, which is atomic. - Show rank lookup with
ZREVRANK.
اختبر فهمك
Why is ZINCRBY better than read-modify-write?
أظهر الإجابة
It is atomic; no lost updates.
التطبيق
طبّق هذا الدرس بمختبر الوحدة وتمارينها واختبارها.
تعليم الدرس كمكتمل اختياري ويمكنك التراجع عنه في أي وقت. يبقى تقدمك محفوظًا في هذا المتصفح.