انتقل إلى المحتوى
أمين أبوزيد
درس مخطط لهMID-038-L07

عرض عملي: تخزين تفاصيل المنتج مؤقتًا باستخدام @Cacheable

  • الدرس 7 من 7
  • Mid-level
في هذا الدرس 3 موضوعات

هذا الدرس مخطط له. يعرض المخطط أدناه الموضوعات التي سيغطيها، ولم يُنشر الدرس الكامل بعد.

نص الدروس والتمارين باللغة الإنجليزية، بينما تبقى واجهة الموقع وعناوين الدروس بالعربية.

في هذا الدرس

cache product details in Redis with a TTL and metrics. Prepares MID-038-LAB1.

تفاصيل المخطط المبدئي

خطوة بخطوة

  1. Add the Redis starter and a RedisCacheManager with a 10-minute TTL for products.
  2. Annotate findProduct with @Cacheable and the update method with @CacheEvict.
  3. Enable cache statistics and read hits/misses in Micrometer (verify the metric names for your Spring Boot version).
  4. Run a load test; compare latency with and without the cache.
  5. Planned mistake: cache a Product entity that is not Serializable and uses Java serialization; it fails or breaks on a class change. Fix: cache a small DTO with JSON serialization.
  6. Show the keys with SCAN 0 MATCH products::*.

اختبر فهمك

Which operation removes a stale product when its price changes?

أظهر الإجابة

@CacheEvict, or event-based invalidation in MID-039.

التطبيق

طبّق هذا الدرس بمختبر الوحدة وتمارينها واختبارها.

المختبر والتمارين الاختبار

تعليم الدرس كمكتمل اختياري ويمكنك التراجع عنه في أي وقت. يبقى تقدمك محفوظًا في هذا المتصفح.

اكتب للبحث في المستويات والمراحل والوحدات والدروس.