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

Redis من Spring

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

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

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

في هذا الدرس

use Redis through Spring Data Redis and cache annotations.

الموضوعات المخطط لها

  • spring-boot-starter-data-redis configures a connection factory; StringRedisTemplate handles strings.
  • RedisTemplate needs serializers; prefer JSON over Java serialization.
  • Enable caching with @EnableCaching, define a RedisCacheManager with per-cache TTL.
  • @Cacheable fills the cache, @CacheEvict removes entries, @CachePut updates.
  • Annotations work through proxies: a self-call inside the same class bypasses the cache.
تفاصيل المخطط المبدئي

عرض عملي

java
@Cacheable(cacheNames = "products", key = "#id")
public ProductDto findProduct(long id) { return repo.load(id); }

RedisCacheConfiguration cfg = RedisCacheConfiguration.defaultCacheConfig()
    .entryTtl(Duration.ofMinutes(10)).disableCachingNullValues();

اختبر فهمك

Why might @Cacheable not work on a method called from the same class?

أظهر الإجابة

The proxy is bypassed.

التطبيق

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

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

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

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