Package org.springframework.cache

Examples of org.springframework.cache.CacheManager


            "were found when only 1 was expected. Remove all but one of the " +
            "CacheManager bean definitions, or implement CachingConfigurer " +
            "to make explicit which CacheManager should be used for " +
            "annotation-driven cache management.");
      }
      CacheManager cacheManager = cacheManagerBeans.iterator().next();
      this.cacheManager = cacheManager;
      // keyGenerator remains null; will fall back to default within CacheInterceptor
    }
    else {
      throw new IllegalStateException("No bean of type CacheManager could be found. " +
View Full Code Here


            "were found when only 1 was expected. Remove all but one of the " +
            "CacheManager bean definitions, or implement CachingConfigurer " +
            "to make explicit which CacheManager should be used for " +
            "annotation-driven cache management.");
      }
      CacheManager cacheManager = cacheManagerBeans.iterator().next();
      this.cacheManager = cacheManager;
      // keyGenerator remains null; will fall back to default within CacheInterceptor
    }
    else {
      throw new IllegalStateException("No bean of type CacheManager could be found. " +
View Full Code Here

    }
  }

  @Test
  public void testCustomCacheManager() {
    CacheManager customCm = ctx.getBean("customCacheManager", CacheManager.class);
    Object key = new Object();
    Object r1 = cs.customCacheManager(key);
    assertSame(r1, cs.customCacheManager(key));

    Cache cache = customCm.getCache("testCache");
    assertNotNull(cache.get(key));
  }
View Full Code Here

      CacheResolver operationCacheResolver;
      if (StringUtils.hasText(operation.getCacheResolver())) {
        operationCacheResolver = getBean(operation.getCacheResolver(), CacheResolver.class);
      }
      else if (StringUtils.hasText(operation.getCacheManager())) {
        CacheManager cacheManager = getBean(operation.getCacheManager(), CacheManager.class);
        operationCacheResolver = new SimpleCacheResolver(cacheManager);
      }
      else {
        operationCacheResolver = getCacheResolver();
      }
View Full Code Here

*/
public class ConcurrentMapCacheManagerTests {

  @Test
  public void testDynamicMode() {
    CacheManager cm = new ConcurrentMapCacheManager();
    Cache cache1 = cm.getCache("c1");
    assertTrue(cache1 instanceof ConcurrentMapCache);
    Cache cache1again = cm.getCache("c1");
    assertSame(cache1again, cache1);
    Cache cache2 = cm.getCache("c2");
    assertTrue(cache2 instanceof ConcurrentMapCache);
    Cache cache2again = cm.getCache("c2");
    assertSame(cache2again, cache2);
    Cache cache3 = cm.getCache("c3");
    assertTrue(cache3 instanceof ConcurrentMapCache);
    Cache cache3again = cm.getCache("c3");
    assertSame(cache3again, cache3);

    cache1.put("key1", "value1");
    assertEquals("value1", cache1.get("key1").get());
    cache1.put("key2", 2);
View Full Code Here

    FooService service = context.getBean(FooService.class);
    fooGetSimple(context, service);
  }

  private void fooGetSimple(ApplicationContext context, FooService service) {
    CacheManager cacheManager = context.getBean(CacheManager.class);

    Cache cache = cacheManager.getCache("testCache");

    Object key = new Object();
    assertCacheMiss(key, cache);

    Object value = service.getSimple(key);
View Full Code Here

*/
public class GuavaCacheManagerTests {

  @Test
  public void testDynamicMode() {
    CacheManager cm = new GuavaCacheManager();
    Cache cache1 = cm.getCache("c1");
    assertTrue(cache1 instanceof GuavaCache);
    Cache cache1again = cm.getCache("c1");
    assertSame(cache1again, cache1);
    Cache cache2 = cm.getCache("c2");
    assertTrue(cache2 instanceof GuavaCache);
    Cache cache2again = cm.getCache("c2");
    assertSame(cache2again, cache2);
    Cache cache3 = cm.getCache("c3");
    assertTrue(cache3 instanceof GuavaCache);
    Cache cache3again = cm.getCache("c3");
    assertSame(cache3again, cache3);

    cache1.put("key1", "value1");
    assertEquals("value1", cache1.get("key1").get());
    cache1.put("key2", 2);
View Full Code Here

    assertThat(valueWrapper.get(), isEqual(v1));
  }

  @Test
  public void testCacheName() throws Exception {
    CacheManager redisCM = new RedisCacheManager(template);
    String cacheName = "s2gx11";
    Cache cache = redisCM.getCache(cacheName);
    assertNotNull(cache);
    assertTrue(redisCM.getCacheNames().contains(cacheName));
  }
View Full Code Here

TOP

Related Classes of org.springframework.cache.CacheManager

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.