org.springframework.cache.ehcache.EhCacheCacheManager Java Examples
The following examples show how to use
org.springframework.cache.ehcache.EhCacheCacheManager.
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: CacheManagerBuilder.java From jsets-shiro-spring-boot-starter with Apache License 2.0 | 6 votes |
private CacheManager decision(org.springframework.cache.CacheManager springCacheManager) { if (springCacheManager instanceof EhCacheCacheManager) { EhCacheManager ehCacheManager = new EhCacheManager(); ehCacheManager.setCacheManager(((EhCacheCacheManager) springCacheManager).getCacheManager()); return ehCacheManager; } if (springCacheManager instanceof org.springframework.data.redis.cache.RedisCacheManager) { GenericJackson2JsonRedisSerializer jsonSerializer = new GenericJackson2JsonRedisSerializer(); RedisTemplate rt = new RedisTemplate<Object, Object>(); rt.setConnectionFactory(SpringContextUtils.getBean(RedisConnectionFactory.class)); rt.setKeySerializer(jsonSerializer); rt.setHashKeySerializer(jsonSerializer); rt.setBeanClassLoader(this.getClass().getClassLoader()); rt.afterPropertiesSet(); RedisCacheManager redisCacheManager = new RedisCacheManager(); redisCacheManager.setRedisTemplate(rt); return redisCacheManager; } return new SpringCacheManager(springCacheManager); }
Example #2
Source File: CacheConfiguration.java From ServiceCutter with Apache License 2.0 | 6 votes |
@Bean public CacheManager cacheManager() { log.debug("Starting Ehcache"); cacheManager = net.sf.ehcache.CacheManager.create(); cacheManager.getConfiguration().setMaxBytesLocalHeap(env.getProperty("cache.ehcache.maxBytesLocalHeap", String.class, "16M")); log.debug("Registering Ehcache Metrics gauges"); Set<EntityType<?>> entities = entityManager.getMetamodel().getEntities(); for (EntityType<?> entity : entities) { String name = entity.getName(); if (name == null || entity.getJavaType() != null) { name = entity.getJavaType().getName(); } Assert.notNull(name, "entity cannot exist without a identifier"); net.sf.ehcache.Cache cache = cacheManager.getCache(name); if (cache != null) { cache.getCacheConfiguration().setTimeToLiveSeconds(env.getProperty("cache.timeToLiveSeconds", Long.class, 3600L)); net.sf.ehcache.Ehcache decoratedCache = InstrumentedEhcache.instrument(metricRegistry, cache); cacheManager.replaceCacheWithDecoratedCache(cache, decoratedCache); } } EhCacheCacheManager ehCacheManager = new EhCacheCacheManager(); ehCacheManager.setCacheManager(cacheManager); return ehCacheManager; }
Example #3
Source File: CacheConfiguration.java From angularjs-springboot-bookstore with MIT License | 6 votes |
@Bean public CacheManager cacheManager() { log.debug("Starting Ehcache"); cacheManager = net.sf.ehcache.CacheManager.create(); cacheManager.getConfiguration().setMaxBytesLocalHeap(env.getProperty("cache.ehcache.maxBytesLocalHeap", String.class, "16M")); log.debug("Registering Ehcache Metrics gauges"); Set<EntityType<?>> entities = entityManager.getMetamodel().getEntities(); for (EntityType<?> entity : entities) { String name = entity.getName(); if (name == null || entity.getJavaType() != null) { name = entity.getJavaType().getName(); } Assert.notNull(name, "entity cannot exist without a identifier"); net.sf.ehcache.Cache cache = cacheManager.getCache(name); if (cache != null) { cache.getCacheConfiguration().setTimeToLiveSeconds(env.getProperty("cache.timeToLiveSeconds", Long.class, 3600L)); net.sf.ehcache.Ehcache decoratedCache = InstrumentedEhcache.instrument(metricRegistry, cache); cacheManager.replaceCacheWithDecoratedCache(cache, decoratedCache); } } EhCacheCacheManager ehCacheManager = new EhCacheCacheManager(); ehCacheManager.setCacheManager(cacheManager); return ehCacheManager; }
Example #4
Source File: ShiroConfig.java From jsets-shiro-spring-boot-starter with Apache License 2.0 | 6 votes |
private void biuldCacheManager() { this.cacheManager = this.customizer.getCacheManager(); if(Objects.isNull(this.cacheManager)) { if(Objects.isNull(springCacheManager)) { this.cacheManager = new MapCacheManager(); }else { if (springCacheManager instanceof EhCacheCacheManager) { EhCacheManager ehCacheManager = new EhCacheManager(); ehCacheManager.setCacheManager(((EhCacheCacheManager) springCacheManager).getCacheManager()); this.cacheManager = ehCacheManager; } if (springCacheManager instanceof org.springframework.data.redis.cache.RedisCacheManager) { RedisCacheManager redisCacheManager = new RedisCacheManager(); redisCacheManager.setRedisTemplate(RedisUtils.imitateRedisTemplate()); this.cacheManager = redisCacheManager; } } } this.cacheDelegator = new CacheDelegator(this.cacheManager); }
Example #5
Source File: CachingConfig3.java From Project with Apache License 2.0 | 5 votes |
@Bean public CacheManager cacheManager(net.sf.ehcache.CacheManager cm, RedisTemplate<String, Object> redisTemplate) { CompositeCacheManager compositeCacheManager = new CompositeCacheManager(); List<CacheManager> managers = new ArrayList<CacheManager>(); managers.add(new EhCacheCacheManager(cm)); managers.add(new RedisCacheManager(redisTemplate)); compositeCacheManager.setCacheManagers(managers);//添加缓存管理器,按添加顺序查找,没找到再往下找 return compositeCacheManager; }
Example #6
Source File: SpringMvcCacheConfig.java From Hands-On-High-Performance-with-Spring-5 with MIT License | 4 votes |
@Bean public CacheManager cacheManager() { return new EhCacheCacheManager(cacheManagerFactoryBean().getObject()); }
Example #7
Source File: CacheConfig.java From api-layer with Eclipse Public License 2.0 | 4 votes |
@Bean public CacheManager cacheManager() { return new EhCacheCacheManager(ehCacheCacheManager().getObject()); }
Example #8
Source File: CacheConfiguration.java From MicroCommunity with Apache License 2.0 | 4 votes |
@Bean(name = "appEhCacheCacheManager") public EhCacheCacheManager ehCacheCacheManager(EhCacheManagerFactoryBean bean){ return new EhCacheCacheManager (bean.getObject()); }
Example #9
Source File: SpringDispatcherConfig.java From Spring-5.0-Cookbook with MIT License | 4 votes |
@Bean public CacheManager cacheManager(){ CacheManager cm = new EhCacheCacheManager( ehCacheCacheManager().getObject()); return cm; }
Example #10
Source File: Ehcache.java From chronus with Apache License 2.0 | 4 votes |
public Ehcache(EhCacheCacheManager ehCacheCacheManager) { this.ehCacheCacheManager = ehCacheCacheManager; }
Example #11
Source File: CachingConfig.java From Project with Apache License 2.0 | 4 votes |
@Bean public EhCacheCacheManager cacheManager(CacheManager cm) { return new EhCacheCacheManager(cm); }
Example #12
Source File: BaseApplicationConfig.java From spring-boot-doma2-sample with Apache License 2.0 | 4 votes |
@Bean public CacheManager cacheManager() { val manager = new EhCacheCacheManager(); manager.setCacheManager(ehcache().getObject()); return manager; }
Example #13
Source File: CacheConfiguration.java From Spring-Boot-Blog with MIT License | 4 votes |
@Bean public EhCacheCacheManager ehCacheCacheManager(){ return new EhCacheCacheManager(ehCacheManagerFactoryBean().getObject()); }
Example #14
Source File: HibernateEhCacheRegionFactory.java From yes-cart with Apache License 2.0 | 4 votes |
/** * Spring IoC. * * @param cacheManager cache manager */ public void setCacheManager(final EhCacheCacheManager cacheManager) { PROVIDER = new SingletonEhCacheRegionFactory(null) {{ manager = cacheManager.getCacheManager(); }}; }
Example #15
Source File: DaoSpringModuleConfig.java From herd with Apache License 2.0 | 4 votes |
@Bean @Override public CacheManager cacheManager() { return new EhCacheCacheManager(ehCacheManager()); }
Example #16
Source File: CacheConfig.java From cc-s with MIT License | 2 votes |
/** * ehcache管理器 * @param bean * @return */ @Bean public EhCacheCacheManager ehCacheCacheManager(EhCacheManagerFactoryBean bean){ return new EhCacheCacheManager(bean.getObject()); }
Example #17
Source File: EhCacheConfig.java From kvf-admin with MIT License | 2 votes |
/** * ehcache 主要的管理器 * * @param cacheManagerFactoryBean cm * @return ec */ @Bean public EhCacheCacheManager ehCacheCacheManager(EhCacheManagerFactoryBean cacheManagerFactoryBean) { return new EhCacheCacheManager(cacheManagerFactoryBean.getObject()); }