هياكل البيانات واستخداماتها
في هذا الدرس 4 موضوعات
هذا الدرس مخطط له. يعرض المخطط أدناه الموضوعات التي سيغطيها، ولم يُنشر الدرس الكامل بعد.
نص الدروس والتمارين باللغة الإنجليزية، بينما تبقى واجهة الموقع وعناوين الدروس بالعربية.
في هذا الدرس
pick the right structure for each problem.
الموضوعات المخطط لها
- String: a value or counter;
SET,GET,INCR,SET key v EX 60. Use for cached JSON and counters. - Hash: field-value map under one key;
HSET,HGET. Use for objects you update field by field. - Set: unique members;
SADD,SISMEMBER. Use for tags, "who liked this". - Sorted set: members with a score, ordered;
ZADD,ZRANGE,ZINCRBY. Use for leaderboards and time-ordered indexes. - Expiration applies to the whole key, not to a hash field or set member.
تفاصيل المخطط المبدئي
عرض عملي
| Problem | Structure |
|---|---|
| Cached product JSON | String with TTL |
| Cart (field per product) | Hash |
| Users who viewed a product | Set |
| Top-selling products | Sorted set |
اختبر فهمك
Which structure gives "top 10 by score" cheaply?
أظهر الإجابة
Sorted set: ZREVRANGE/ZRANGE ... REV.
التطبيق
طبّق هذا الدرس بمختبر الوحدة وتمارينها واختبارها.
تعليم الدرس كمكتمل اختياري ويمكنك التراجع عنه في أي وقت. يبقى تقدمك محفوظًا في هذا المتصفح.