Java Code Examples for org.springframework.cache.support.SimpleCacheManager#setCaches()
The following examples show how to use
org.springframework.cache.support.SimpleCacheManager#setCaches() .
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-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 3
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 4
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 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: 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 7
Source File: CacheTestUtils.java From spring4-understanding with Apache License 2.0 | 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<Cache>(); for (String cacheName : cacheNames) { caches.add(new ConcurrentMapCache(cacheName)); } result.setCaches(caches); result.afterPropertiesSet(); return result; }
Example 8
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; }
Example 9
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 10
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 11
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 12
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 13
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 14
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 15
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 16
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 17
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 18
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 19
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 20
Source File: CachingConfiguration.java From spring-data-examples with Apache License 2.0 | 3 votes |
@Bean public CacheManager cacheManager() { Cache cache = new ConcurrentMapCache("byUsername"); SimpleCacheManager manager = new SimpleCacheManager(); manager.setCaches(Arrays.asList(cache)); return manager; }