@Test public void test_should_delete_computed_messages_cached_from_db_for_a_given_locale_tenant_and_its_derived_tenants() { final Tenant tenant = new Tenant("a.b"); final String locale = "en_IN"; final List<Object> cacheKeys = Arrays.asList("mr_IN:a.b", "en_IN:a.b", "mr_IN:a.b.c", "en_IN:a.b.c", "mr_IN:a.b.d", "en_IN:a.b.d", "en_IN:d.e"); when(hashOperations.keys(COMPUTED_MESSAGE_HASH_KEY)).thenReturn(new HashSet<>(cacheKeys)); cacheRepository.bustCacheEntry(locale, tenant); verify(hashOperations).delete(COMPUTED_MESSAGE_HASH_KEY, "en_IN:a.b"); verify(hashOperations).delete(COMPUTED_MESSAGE_HASH_KEY, "en_IN:a.b.c"); verify(hashOperations).delete(COMPUTED_MESSAGE_HASH_KEY, "en_IN:a.b.d"); }
public void bustCacheEntry(String locale, Tenant tenant) { bustRawMessagesCacheEntry(locale, tenant); bustComputedMessagesCache(locale, tenant); }
MessageCacheRepository { public void bustCacheEntry(String locale, Tenant tenant) { bustRawMessagesCacheEntry(locale, tenant); bustComputedMessagesCache(locale, tenant); } }
MessageCacheRepository { public void bustCacheEntry(String locale, Tenant tenant) { bustRawMessagesCacheEntry(locale, tenant); bustComputedMessagesCache(locale, tenant); } MessageCacheRepository(StringRedisTemplate stringRedisTemplate, ObjectMapper objectMapper); }
MessageCacheRepository { public void bustCacheEntry(String locale, Tenant tenant) { bustRawMessagesCacheEntry(locale, tenant); bustComputedMessagesCache(locale, tenant); } MessageCacheRepository(StringRedisTemplate stringRedisTemplate, ObjectMapper objectMapper); List<Message> getComputedMessages(String locale, Tenant tenant); void cacheComputedMessages(String locale, Tenant tenant, List<Message> messages); List<Message> getMessages(String locale, Tenant tenant); void cacheMessages(String locale, Tenant tenant, List<Message> messages); void bustCache(); void bustCacheEntry(String locale, Tenant tenant); }
MessageCacheRepository { public void bustCacheEntry(String locale, Tenant tenant) { bustRawMessagesCacheEntry(locale, tenant); bustComputedMessagesCache(locale, tenant); } MessageCacheRepository(StringRedisTemplate stringRedisTemplate, ObjectMapper objectMapper); List<Message> getComputedMessages(String locale, Tenant tenant); void cacheComputedMessages(String locale, Tenant tenant, List<Message> messages); List<Message> getMessages(String locale, Tenant tenant); void cacheMessages(String locale, Tenant tenant, List<Message> messages); void bustCache(); void bustCacheEntry(String locale, Tenant tenant);  }