I think that @mavarazy answer is the best. I only add if you need you own automatic missed cache configuration you could do it on the following way.
First define you own cache manager which creates automatically cache if you need it:
public class MyCacheManager extends SimpleCacheManager {
@Override
protected Cache getMissingCache(String name) {
// or different cache config if you need
return new GuavaCache(name, CacheBuilder.newBuilder().maximumSize(250).expireAfterWrite(10, TimeUnit.MINUTES).build());
}
}
And now you can define cache manager configuration:
@Bean
public CacheManager cacheManager() {
SimpleCacheManager simpleCacheManager = new MyCacheManager();
GuavaCache specificCacheConfig = new GuavaCache("specificCacheConfigName",
CacheBuilder.newBuilder().expireAfterAccess(60, TimeUnit.MINUTES).build());
simpleCacheManager.setCaches(Collections.singletonList(specificCacheConfig));
return simpleCacheManager;
}