spring-cache

cannot access net.sf.ehcache.CacheManager, class file for net.sf.ehcache.CacheManager not found

China☆狼群 提交于 2021-02-07 14:29:24
问题 I have been implementing some caching in my project using EhCache . I have added following dependencies to my pom.xml <!-- https://mvnrepository.com/artifact/org.springframework/spring-context --> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context</artifactId> <version>4.3.8.RELEASE</version> </dependency> <!-- https://mvnrepository.com/artifact/org.springframework/spring-context-support --> <dependency> <groupId>org.springframework</groupId> <artifactId>spring

How can I prefix cacheNames with spring.cache.redis.key-prefix?

限于喜欢 提交于 2021-01-29 11:00:47
问题 I managed to make the cacheNames work and my Redis keys look like this. {cacheName}::{myKey} {cacheName}::{myKey} Now I wonder how can I prefix the {cacheName} part with my configured value of spring.cache.redis.key-prefix ? When I put these entries, spring.cache.redis.key-prefix=some:: spring.cache.redis.use-key-prefix=true I want the keys look like this. some::{cacheName}::{myKey} some::{cacheName}::{myKey} 回答1: I'm not sure of the way of using configuration along with internal

Set cache expireAfterWrite property dynamically - Caffeine and Spring WebFlux

守給你的承諾、 提交于 2021-01-29 09:41:11
问题 I am using caffeine cache to store an authorisation token that has been obtained using webClient WebFlux. I have set the expireAfterWrite to a hardcoded value in the application.yml file as follows: spring: cache: cache-names: accessTokens caffeine: spec: expireAfterWrite=100m The token is obtained using a WebClient with Spring WebFlux as below code depicts: @Autowired var cacheManager: CacheManager? = null override fun getAuthToken(): Mono<AccessToken> { val map = LinkedMultiValueMap<String,

SpringCacheBasedUserCache is null

梦想与她 提交于 2021-01-28 22:22:32
问题 I have web applicatoin who use spring boot, spring security and spring data. it is stateless. I would like to avoid to alway call db for user acess. So i thinking using SpringCacheBasedUserCache. @Configuration @EnableCaching public class CacheConfig { @Bean CacheManager cacheManager() { SimpleCacheManager cacheManager = new SimpleCacheManager(); cacheManager.setCaches(Arrays.asList(new ConcurrentMapCache("city"), new ConcurrentMapCache("userCache"))); return cacheManager; } @Bean public

Spring Boot Cachable Cache Size

前提是你 提交于 2021-01-28 18:30:49
问题 I want to to configure my cache size. I am using @EnableCaching . Here is my cached repository. VendorRepository public interface VendorRepository extends Repository<Vendor, Long> { @Cacheable("vendorByUsername") Vendor getVendorByUsername(String username); @CacheEvict(value = {"vendorByUsername", "vendor", "vendors"}, allEntries = true) Vendor save(Vendor vendor); @Cacheable("vendor") Vendor findOne(Long id); @Cacheable("vendors") List<Vendor> findAll(); } It is working good right now but I

Spring cloud gateway with Spring cache and caffeine

試著忘記壹切 提交于 2021-01-07 01:23:09
问题 I have a spring cloud gateway which forwards the API rest requests to some microservices. I would like to cache the response for specific requests. For this reason I wrote this Filter @Component @Slf4j public class CacheResponseGatewayFilterFactory extends AbstractGatewayFilterFactory<CacheResponseGatewayFilterFactory.Config> { private final CacheManager cacheManager; public CacheResponseGatewayFilterFactory(CacheManager cacheManager) { super(CacheResponseGatewayFilterFactory.Config.class);

Spring cloud gateway with Spring cache and caffeine

橙三吉。 提交于 2021-01-07 01:23:00
问题 I have a spring cloud gateway which forwards the API rest requests to some microservices. I would like to cache the response for specific requests. For this reason I wrote this Filter @Component @Slf4j public class CacheResponseGatewayFilterFactory extends AbstractGatewayFilterFactory<CacheResponseGatewayFilterFactory.Config> { private final CacheManager cacheManager; public CacheResponseGatewayFilterFactory(CacheManager cacheManager) { super(CacheResponseGatewayFilterFactory.Config.class);

Spring cloud gateway with Spring cache and caffeine

北城余情 提交于 2021-01-07 01:22:35
问题 I have a spring cloud gateway which forwards the API rest requests to some microservices. I would like to cache the response for specific requests. For this reason I wrote this Filter @Component @Slf4j public class CacheResponseGatewayFilterFactory extends AbstractGatewayFilterFactory<CacheResponseGatewayFilterFactory.Config> { private final CacheManager cacheManager; public CacheResponseGatewayFilterFactory(CacheManager cacheManager) { super(CacheResponseGatewayFilterFactory.Config.class);