Package org.springframework.cache.concurrent

Examples of org.springframework.cache.concurrent.ConcurrentMapCache


  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;
  }
View Full Code Here


    @Bean
    public CacheManager cacheManager() {
      SimpleCacheManager cm = new SimpleCacheManager();
      cm.setCaches(Arrays.asList(
          defaultCache(),
          new ConcurrentMapCache("primary"),
          new ConcurrentMapCache("secondary"),
          new ConcurrentMapCache("exception")));
      return cm;
    }
View Full Code Here

      return new AnnotatedJCacheableService(defaultCache());
    }

    @Bean
    public Cache defaultCache() {
      return new ConcurrentMapCache("default");
    }
View Full Code Here

    @Bean
    public CacheManager cacheManager() {
      SimpleCacheManager cm = new SimpleCacheManager();
      cm.setCaches(Arrays.asList(
          defaultCache(),
          new ConcurrentMapCache("primary"),
          new ConcurrentMapCache("secondary"),
          new ConcurrentMapCache("exception")));
      return cm;
    }
View Full Code Here

      return new AnnotatedJCacheableService(defaultCache());
    }

    @Bean
    public Cache defaultCache() {
      return new ConcurrentMapCache("default");
    }
View Full Code Here

      return new AnnotatedJCacheableService(defaultCache());
    }

    @Bean
    public Cache defaultCache() {
      return new ConcurrentMapCache("default");
    }
View Full Code Here

      return new ConcurrentMapCache("default");
    }

    @Bean
    public Cache exceptionCache() {
      return new ConcurrentMapCache("exception");
    }
View Full Code Here

    new TransactionAwareCacheDecorator(null);
  }

  @Test
  public void regularOperationsOnTarget() {
    Cache target = new ConcurrentMapCache("testCache");
    Cache cache = new TransactionAwareCacheDecorator(target);
    assertEquals(target.getName(), cache.getName());
    assertEquals(target.getNativeCache(), cache.getNativeCache());

    Object key = new Object();
    target.put(key, "123");
    assertEquals("123", cache.get(key).get());
    assertEquals("123", cache.get(key, String.class));

    cache.clear();
    assertNull(target.get(key));
  }
View Full Code Here

    assertNull(target.get(key));
  }

  @Test
  public void putNonTransactional() {
    Cache target = new ConcurrentMapCache("testCache");
    Cache cache = new TransactionAwareCacheDecorator(target);

    Object key = new Object();
    cache.put(key, "123");
    assertEquals("123", target.get(key, String.class));
  }
View Full Code Here

    assertEquals("123", target.get(key, String.class));
  }

  @Test
  public void putTransactional() {
    Cache target = new ConcurrentMapCache("testCache");
    Cache cache = new TransactionAwareCacheDecorator(target);

    TransactionStatus status = txManager.getTransaction(new DefaultTransactionAttribute(
        TransactionDefinition.PROPAGATION_REQUIRED));

    Object key = new Object();
    cache.put(key, "123");
    assertNull(target.get(key));
    txManager.commit(status);

    assertEquals("123", target.get(key, String.class));
  }
View Full Code Here

TOP

Related Classes of org.springframework.cache.concurrent.ConcurrentMapCache

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.