refactor code

This commit is contained in:
saikat 2024-03-01 16:03:55 +05:30
parent 5b7a864ef2
commit 03f52e6329
8 changed files with 17 additions and 31 deletions

View File

@ -1,12 +0,0 @@
package com.baeldung.caching.multicache;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class MultipleCachingApplication {
public static void main(String[] args) {
SpringApplication.run(MultipleCachingApplication.class, args);
}
}

View File

@ -1,4 +1,4 @@
package com.baeldung.caching.multicache;
package com.baeldung.caching.twolevelcache;
import com.github.benmanes.caffeine.cache.Caffeine;
import org.springframework.cache.CacheManager;
@ -28,8 +28,7 @@ public class CacheConfig {
@Primary
public CacheManager caffeineCacheManager() {
SimpleCacheManager manager = new SimpleCacheManager();
manager.setCaches(Arrays.asList(
caffeineCacheConfig()));
manager.setCaches(Arrays.asList(caffeineCacheConfig()));
return manager;
}

View File

@ -1,4 +1,4 @@
package com.baeldung.caching.multicache;
package com.baeldung.caching.twolevelcache;
import lombok.AllArgsConstructor;
import lombok.Data;

View File

@ -1,4 +1,4 @@
package com.baeldung.caching.multicache;
package com.baeldung.caching.twolevelcache;
import org.springframework.cache.Cache;
import org.springframework.cache.CacheManager;

View File

@ -1,7 +1,6 @@
package com.baeldung.caching.multicache;
package com.baeldung.caching.twolevelcache;
import org.springframework.data.repository.CrudRepository;
public interface CustomerRepository extends CrudRepository<Customer, String> {
}

View File

@ -1,4 +1,4 @@
package com.baeldung.caching.multicache;
package com.baeldung.caching.twolevelcache;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;

View File

@ -1,5 +1,10 @@
package com.baeldung.caching.redis;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.BDDMockito.given;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
@ -19,11 +24,6 @@ import javax.annotation.PreDestroy;
import java.io.IOException;
import java.util.Optional;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.BDDMockito.given;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
@Import({ CacheConfig.class, ItemService.class })
@ExtendWith(SpringExtension.class)
@ImportAutoConfiguration(classes = { CacheAutoConfiguration.class, RedisAutoConfiguration.class })

View File

@ -1,4 +1,9 @@
package com.baeldung.caching.multicache;
package com.baeldung.caching.twolevelcache;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.BDDMockito.given;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
@ -21,11 +26,6 @@ import java.io.IOException;
import java.util.Optional;
import java.util.concurrent.TimeUnit;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.BDDMockito.given;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
@Import({ CacheConfig.class,CustomerService.class })
@ExtendWith(SpringExtension.class)
@ImportAutoConfiguration(classes = { CacheAutoConfiguration.class, RedisAutoConfiguration.class })