org.springframework.cache.support.SimpleCacheManager Java Examples
The following examples show how to use
org.springframework.cache.support.SimpleCacheManager.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CacheConfig.java From ProxyPool with Apache License 2.0 | 7 votes |
/** * 创建基于Caffeine的Cache Manager * @return */ @Bean @Primary public CacheManager caffeineCacheManager() { SimpleCacheManager cacheManager = new SimpleCacheManager(); ArrayList<CaffeineCache> caches = new ArrayList<CaffeineCache>(); for(Caches c : Caches.values()){ caches.add(new CaffeineCache(c.name(), Caffeine.newBuilder().recordStats() .expireAfterWrite(c.getTtl(), TimeUnit.SECONDS) .maximumSize(c.getMaxSize()) .build()) ); } cacheManager.setCaches(caches); return cacheManager; }
Example #2
Source File: CacheConfig.java From spring-boot-redis-guava-caffeine-cache with Apache License 2.0 | 6 votes |
/** * 个性化配置缓存 */ @Bean public CacheManager cacheManager() { SimpleCacheManager manager = new SimpleCacheManager(); //把各个cache注册到cacheManager中,CaffeineCache实现了org.springframework.cache.Cache接口 ArrayList<CaffeineCache> caches = new ArrayList<>(); for (Caches c : Caches.values()) { caches.add(new CaffeineCache(c.name(), Caffeine.newBuilder().recordStats() .expireAfterWrite(c.getTtl(), TimeUnit.SECONDS) .maximumSize(c.getMaxSize()) .build()) ); } manager.setCaches(caches); return manager; }
Example #3
Source File: CacheConfig.java From spring-boot-101 with Apache License 2.0 | 6 votes |
/** * 创建基于Caffeine的Cache Manager * @return */ @Bean @Primary public CacheManager caffeineCacheManager() { SimpleCacheManager cacheManager = new SimpleCacheManager(); ArrayList<CaffeineCache> caches = new ArrayList<CaffeineCache>(); for(Caches c : Caches.values()){ caches.add(new CaffeineCache(c.name(), Caffeine.newBuilder().recordStats() .expireAfterWrite(c.getTtl(), TimeUnit.SECONDS) .maximumSize(c.getMaxSize()) .build()) ); } cacheManager.setCaches(caches); return cacheManager; }
Example #4
Source File: EnableTransactionManagementIntegrationTests.java From spring-analysis-note with MIT License | 5 votes |
@Bean public CacheManager cacheManager() { SimpleCacheManager mgr = new SimpleCacheManager(); ArrayList<Cache> caches = new ArrayList<>(); caches.add(new ConcurrentMapCache("")); mgr.setCaches(caches); return mgr; }
Example #5
Source File: CachingConfig.java From cloudbreak with Apache License 2.0 | 5 votes |
@Bean public CacheManager cacheManager() { SimpleCacheManager simpleCacheManager = new SimpleCacheManager(); Set<Cache> caches = cacheDefinitions.stream().map(CacheDefinition::cacheConfiguration).collect(Collectors.toSet()); simpleCacheManager.setCaches(caches); return simpleCacheManager; }
Example #6
Source File: CachingConfig.java From cloudbreak with Apache License 2.0 | 5 votes |
@Bean public CacheManager cacheManager() { SimpleCacheManager simpleCacheManager = new SimpleCacheManager(); Set<Cache> caches = cacheDefinitions.stream().map(CacheDefinition::cacheConfiguration).collect(Collectors.toSet()); simpleCacheManager.setCaches(caches); simpleCacheManager.initializeCaches(); return simpleCacheManager; }
Example #7
Source File: CachingConfig.java From cloudbreak with Apache License 2.0 | 5 votes |
@Bean public CacheManager cacheManager() { SimpleCacheManager simpleCacheManager = new SimpleCacheManager(); Set<Cache> caches = cacheDefinitions.stream().map(CacheDefinition::cacheConfiguration).collect(Collectors.toSet()); simpleCacheManager.setCaches(caches); return simpleCacheManager; }
Example #8
Source File: ReferenceApplication.java From aws-refapp with Apache License 2.0 | 5 votes |
@Bean public CacheManager createSimpleCacheManager() { SimpleCacheManager simpleCacheManager = new SimpleCacheManager(); List<Cache> caches = new ArrayList<>(2); caches.add(new ConcurrentMapCache("CacheCluster")); caches.add(new ConcurrentMapCache("GitHubSourceCode")); simpleCacheManager.setCaches(caches); return simpleCacheManager; }
Example #9
Source File: ElastiCacheCacheConfigurer.java From spring-cloud-aws with Apache License 2.0 | 5 votes |
@Override public CacheManager cacheManager() { List<Cache> caches = new ArrayList<>(this.cacheNames.size()); for (String cacheName : this.cacheNames) { caches.add(clusterCache(cacheName)); } SimpleCacheManager simpleCacheManager = new SimpleCacheManager(); simpleCacheManager.setCaches(caches); simpleCacheManager.afterPropertiesSet(); return simpleCacheManager; }
Example #10
Source File: GuavaConfig.java From spring-boot-redis-guava-caffeine-cache with Apache License 2.0 | 5 votes |
/** * 个性化配置缓存 */ @Bean public CacheManager cacheManager() { SimpleCacheManager manager = new SimpleCacheManager(); //把各个cache注册到cacheManager中,GuavaCache实现了org.springframework.cache.Cache接口 ArrayList<GuavaCache> caches = new ArrayList<>(); for (Caches c : Caches.values()) { caches.add(new GuavaCache(c.name(), CacheBuilder.newBuilder().recordStats().expireAfterWrite(c.getTtl(), TimeUnit.SECONDS).maximumSize(c.getMaxSize()).build())); } manager.setCaches(caches); return manager; }
Example #11
Source File: CachingConfig.java From mojito with Apache License 2.0 | 5 votes |
@Bean @Override public CacheManager cacheManager() { Cache defaultCache = new ConcurrentMapCache("default"); Cache localesCache = new ConcurrentMapCache("locales"); Cache pluralForm = new ConcurrentMapCache("pluralForms"); SimpleCacheManager manager = new SimpleCacheManager(); manager.setCaches(Arrays.asList(defaultCache, localesCache, pluralForm)); return manager; }
Example #12
Source File: JCacheAspectJJavaConfigTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Bean public CacheManager cacheManager() { SimpleCacheManager cm = new SimpleCacheManager(); cm.setCaches(Arrays.asList( defaultCache(), new ConcurrentMapCache("primary"), new ConcurrentMapCache("secondary"), new ConcurrentMapCache("exception"))); return cm; }
Example #13
Source File: JCacheCustomInterceptorTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Bean public CacheManager cacheManager() { SimpleCacheManager cm = new SimpleCacheManager(); cm.setCaches(Arrays.asList( defaultCache(), exceptionCache())); return cm; }
Example #14
Source File: JCacheJavaConfigTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Bean public CacheManager cacheManager() { SimpleCacheManager cm = new SimpleCacheManager(); cm.setCaches(Arrays.asList( defaultCache(), new ConcurrentMapCache("primary"), new ConcurrentMapCache("secondary"), new ConcurrentMapCache("exception"))); return cm; }
Example #15
Source File: AbstractJCacheTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
protected static CacheManager createSimpleCacheManager(String... cacheNames) { SimpleCacheManager result = new SimpleCacheManager(); List<Cache> caches = new ArrayList<Cache>(); for (String cacheName : cacheNames) { caches.add(new ConcurrentMapCache(cacheName)); } result.setCaches(caches); result.afterPropertiesSet(); return result; }
Example #16
Source File: EnableTransactionManagementIntegrationTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Bean public CacheManager cacheManager() { SimpleCacheManager mgr = new SimpleCacheManager(); ArrayList<Cache> caches = new ArrayList<Cache>(); caches.add(new ConcurrentMapCache("")); mgr.setCaches(caches); return mgr; }
Example #17
Source File: CacheConfig.java From microservices-sample-project with Apache License 2.0 | 5 votes |
public static CacheManager createCacheManager(String... caches) { List<ConcurrentMapCache> concurrentMapCaches = new ArrayList<>(); for(String cacheName : caches){ concurrentMapCaches.add(new ConcurrentMapCache(cacheName)); concurrentMapCaches.add(new ConcurrentMapCache(cacheName + CONCAT + SUFFIX)); } SimpleCacheManager cacheManager = new SimpleCacheManager(); cacheManager.setCaches(concurrentMapCaches); return cacheManager; }
Example #18
Source File: CacheTestUtils.java From spring-analysis-note with MIT License | 5 votes |
/** * Create a {@link SimpleCacheManager} with the specified cache(s). * @param cacheNames the names of the caches to create */ public static CacheManager createSimpleCacheManager(String... cacheNames) { SimpleCacheManager result = new SimpleCacheManager(); List<Cache> caches = new ArrayList<>(); for (String cacheName : cacheNames) { caches.add(new ConcurrentMapCache(cacheName)); } result.setCaches(caches); result.afterPropertiesSet(); return result; }
Example #19
Source File: AbstractJCacheTests.java From spring-analysis-note with MIT License | 5 votes |
protected static CacheManager createSimpleCacheManager(String... cacheNames) { SimpleCacheManager result = new SimpleCacheManager(); List<Cache> caches = new ArrayList<>(); for (String cacheName : cacheNames) { caches.add(new ConcurrentMapCache(cacheName)); } result.setCaches(caches); result.afterPropertiesSet(); return result; }
Example #20
Source File: JCacheJavaConfigTests.java From spring-analysis-note with MIT License | 5 votes |
@Bean public CacheManager cacheManager() { SimpleCacheManager cm = new SimpleCacheManager(); cm.setCaches(Arrays.asList( defaultCache(), new ConcurrentMapCache("primary"), new ConcurrentMapCache("secondary"), new ConcurrentMapCache("exception"))); return cm; }
Example #21
Source File: JCacheCustomInterceptorTests.java From spring-analysis-note with MIT License | 5 votes |
@Bean public CacheManager cacheManager() { SimpleCacheManager cm = new SimpleCacheManager(); cm.setCaches(Arrays.asList( defaultCache(), exceptionCache())); return cm; }
Example #22
Source File: JCacheAspectJJavaConfigTests.java From spring-analysis-note with MIT License | 5 votes |
@Bean public CacheManager cacheManager() { SimpleCacheManager cm = new SimpleCacheManager(); cm.setCaches(Arrays.asList( defaultCache(), new ConcurrentMapCache("primary"), new ConcurrentMapCache("secondary"), new ConcurrentMapCache("exception"))); return cm; }
Example #23
Source File: CacheTestUtils.java From java-technology-stack with MIT License | 5 votes |
/** * Create a {@link SimpleCacheManager} with the specified cache(s). * @param cacheNames the names of the caches to create */ public static CacheManager createSimpleCacheManager(String... cacheNames) { SimpleCacheManager result = new SimpleCacheManager(); List<Cache> caches = new ArrayList<>(); for (String cacheName : cacheNames) { caches.add(new ConcurrentMapCache(cacheName)); } result.setCaches(caches); result.afterPropertiesSet(); return result; }
Example #24
Source File: EnableTransactionManagementIntegrationTests.java From java-technology-stack with MIT License | 5 votes |
@Bean public CacheManager cacheManager() { SimpleCacheManager mgr = new SimpleCacheManager(); ArrayList<Cache> caches = new ArrayList<>(); caches.add(new ConcurrentMapCache("")); mgr.setCaches(caches); return mgr; }
Example #25
Source File: AbstractJCacheTests.java From java-technology-stack with MIT License | 5 votes |
protected static CacheManager createSimpleCacheManager(String... cacheNames) { SimpleCacheManager result = new SimpleCacheManager(); List<Cache> caches = new ArrayList<>(); for (String cacheName : cacheNames) { caches.add(new ConcurrentMapCache(cacheName)); } result.setCaches(caches); result.afterPropertiesSet(); return result; }
Example #26
Source File: JCacheJavaConfigTests.java From java-technology-stack with MIT License | 5 votes |
@Bean public CacheManager cacheManager() { SimpleCacheManager cm = new SimpleCacheManager(); cm.setCaches(Arrays.asList( defaultCache(), new ConcurrentMapCache("primary"), new ConcurrentMapCache("secondary"), new ConcurrentMapCache("exception"))); return cm; }
Example #27
Source File: JCacheCustomInterceptorTests.java From java-technology-stack with MIT License | 5 votes |
@Bean public CacheManager cacheManager() { SimpleCacheManager cm = new SimpleCacheManager(); cm.setCaches(Arrays.asList( defaultCache(), exceptionCache())); return cm; }
Example #28
Source File: JCacheAspectJJavaConfigTests.java From java-technology-stack with MIT License | 5 votes |
@Bean public CacheManager cacheManager() { SimpleCacheManager cm = new SimpleCacheManager(); cm.setCaches(Arrays.asList( defaultCache(), new ConcurrentMapCache("primary"), new ConcurrentMapCache("secondary"), new ConcurrentMapCache("exception"))); return cm; }
Example #29
Source File: CacheConfiguration.java From GreenSummer with GNU Lesser General Public License v2.1 | 5 votes |
/** * The cache manager Bean, that defines caching parameters * * @param ticker The Ticker handle that Spring passes, unused so far * @return the cache manager */ @Bean public CacheManager cacheManager(Ticker ticker) { SimpleCacheManager manager = new SimpleCacheManager(); if (specs != null) { //@formatter:off List<CaffeineCache> caches = specs.entrySet().stream() .map(entry -> buildCache(entry.getKey(), entry.getValue(), ticker)) .collect(Collectors.toList()); //@formatter:on manager.setCaches(caches); } return manager; }
Example #30
Source File: CaffeineCacheConfiguration.java From Groza with Apache License 2.0 | 5 votes |
@Bean public CacheManager cacheManager() { SimpleCacheManager manager = new SimpleCacheManager(); if (specs != null) { List<CaffeineCache> caches = specs.entrySet().stream() .map(entry -> buildCache(entry.getKey(), entry.getValue())) .collect(Collectors.toList()); manager.setCaches(caches); } return manager; }