Redis من Spring
في هذا الدرس 4 موضوعات
هذا الدرس مخطط له. يعرض المخطط أدناه الموضوعات التي سيغطيها، ولم يُنشر الدرس الكامل بعد.
نص الدروس والتمارين باللغة الإنجليزية، بينما تبقى واجهة الموقع وعناوين الدروس بالعربية.
في هذا الدرس
use Redis through Spring Data Redis and cache annotations.
الموضوعات المخطط لها
spring-boot-starter-data-redisconfigures a connection factory;StringRedisTemplatehandles strings.RedisTemplateneeds serializers; prefer JSON over Java serialization.- Enable caching with
@EnableCaching, define aRedisCacheManagerwith per-cache TTL. @Cacheablefills the cache,@CacheEvictremoves entries,@CachePutupdates.- Annotations work through proxies: a self-call inside the same class bypasses the cache.
تفاصيل المخطط المبدئي
عرض عملي
@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.
التطبيق
طبّق هذا الدرس بمختبر الوحدة وتمارينها واختبارها.
تعليم الدرس كمكتمل اختياري ويمكنك التراجع عنه في أي وقت. يبقى تقدمك محفوظًا في هذا المتصفح.