spring-cache

Is it possible to set a different specification per cache using caffeine in spring boot?

坚强是说给别人听的谎言 提交于 2019-12-03 08:48:23
问题 I have a simple sprint boot application using spring boot 1.5.11.RELEASE with @EnableCaching on the Application Configuration class. pom.xml <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-cache</artifactId> </dependency> <dependency> <groupId>com.github.ben-manes.caffeine</groupId> <artifactId>caffeine</artifactId> </dependency> application.properties spring.cache.type=caffeine spring.cache.cache-names=cache-a,cache-b spring.cache.caffeine.spec

ACL security in Spring Boot

。_饼干妹妹 提交于 2019-12-03 03:51:47
I am having issues setting up ACL through Java config in a Spring Boot application. I have created one small project to reproduce the issues. I have tried a few different approaches. First issue I had was with EhCache, and after I fixed that (I assume I did) I couldn't login any more, and it looks like all the data is gone. There are 4 classes with different configurations: ACLConfig1.class ACLConfig2.class ACLConfig3.class ACLConfig4.class All @PreAuthorize and @PostAuthorize annotations are working as expected, except hasPermission . Controller holds 4 endpoints: one for User, one for Admin,

Is it possible to set a different specification per cache using caffeine in spring boot?

北慕城南 提交于 2019-12-02 22:43:48
I have a simple sprint boot application using spring boot 1.5.11.RELEASE with @EnableCaching on the Application Configuration class. pom.xml <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-cache</artifactId> </dependency> <dependency> <groupId>com.github.ben-manes.caffeine</groupId> <artifactId>caffeine</artifactId> </dependency> application.properties spring.cache.type=caffeine spring.cache.cache-names=cache-a,cache-b spring.cache.caffeine.spec=maximumSize=100, expireAfterWrite=1d Question My question is simple, how can one specify a different size

spring-boot-devtools causing ClassCastException while getting from cache.

霸气de小男生 提交于 2019-11-30 14:04:11
I am facing issue while getting value from cache. java.lang.RuntimeException: java.lang.ClassCastException: com.mycom.admin.domain.User cannot be cast to com.mycom.admin.domain.User Cache Configuration @Configuration @EnableCaching @AutoConfigureAfter(value = { MetricsConfiguration.class, DatabaseConfiguration.class }) @Profile("!" + Constants.SPRING_PROFILE_FAST) public class MemcachedCacheConfiguration extends CachingConfigurerSupport { private final Logger log = LoggerFactory.getLogger(MemcachedCacheConfiguration.class); @Override @Bean public CacheManager cacheManager() {

Multiple Caffeine LoadingCaches added to Spring CaffeineCacheManager

旧巷老猫 提交于 2019-11-30 13:07:34
I'm looking to add several distinct LoadingCache 's to a Spring CacheManager , however I don't see how this is possible using CaffeineCacheManager . It appears that only a single loader is possible for refreshing content, however I need separate loaders for each cache. Is it possible to add multiple loading caches to a Spring cache manager? If so, then how? CaffeineCacheManager cacheManage = new CaffeineCacheManager(); LoadingCache<String, Optional<Edition>> loadingCache1 = Caffeine.newBuilder() .maximumSize(150) .refreshAfterWrite(5, TimeUnit.MINUTES) .build(test -> this.testRepo.find(test));

Generating unique cache key with Spring KeyGenerator not working

北战南征 提交于 2019-11-30 13:06:21
I'm having the issue when my cache keys are colliding in Spring using the @Cacheable annotation. For instance, with the following two methods: @Cacheable("doOneThing") public void doOneThing(String name) { // do something with name } @Cacheable("doAnotherThing") public void doAnotherThing(String name) { // do some other thing with name } Here is my cache configuration, in which I've added a keyGenerator and a cacheManager bean: @Configuration @EnableCaching public class CacheConfig { @Bean public JedisConnectionFactory redisConnectionFactory() { return new JedisConnectionFactory(); } @Bean

Spring cache using @Cacheable during @PostConstruct does not work

一个人想着一个人 提交于 2019-11-30 09:49:29
related to the commit in spring framework https://github.com/spring-projects/spring-framework/commit/5aefcc802ef05abc51bbfbeb4a78b3032ff9eee3 the initialisation is set to a later stage from afterPropertiesSet() to afterSingletonsInstantiated() In short : This prevents the caching to work when using it in a @PostConstruct use case. Longer version : This prevents the use case where you would create serviceB with @Cacheable on a methodB create serviceA with @PostConstruct calling serviceB.methodB @Component public class ServiceA{ @Autowired private ServiceB serviceB; @PostConstruct public void

How to disable Redis Caching at run time if redis connection failed

只谈情不闲聊 提交于 2019-11-30 08:46:17
We have rest api application. We use redis for API response caching and internal method caching. If redis connection then it is making our API down. We want to bypass the redis caching if that redis connection fails or any exception instead of making our API down. There is a interface CacheErrorHandler but it handles the redis get set operation failures not redis connection problems. We are using Spring 4.1.2. Let's boil this down a bit. Your application uses caching (implemented with Redis). If the Redis connection is stale/closed or otherwise, then you want the application to bypass caching

Multiple Caffeine LoadingCaches added to Spring CaffeineCacheManager

蹲街弑〆低调 提交于 2019-11-29 18:37:35
问题 I'm looking to add several distinct LoadingCache 's to a Spring CacheManager , however I don't see how this is possible using CaffeineCacheManager . It appears that only a single loader is possible for refreshing content, however I need separate loaders for each cache. Is it possible to add multiple loading caches to a Spring cache manager? If so, then how? CaffeineCacheManager cacheManage = new CaffeineCacheManager(); LoadingCache<String, Optional<Edition>> loadingCache1 = Caffeine

Generating unique cache key with Spring KeyGenerator not working

血红的双手。 提交于 2019-11-29 18:29:58
问题 I'm having the issue when my cache keys are colliding in Spring using the @Cacheable annotation. For instance, with the following two methods: @Cacheable("doOneThing") public void doOneThing(String name) { // do something with name } @Cacheable("doAnotherThing") public void doAnotherThing(String name) { // do some other thing with name } Here is my cache configuration, in which I've added a keyGenerator and a cacheManager bean: @Configuration @EnableCaching public class CacheConfig { @Bean