Search in sources :

Example 1 with CoherenceCache

use of com.oracle.coherence.spring.cache.CoherenceCache in project coherence-spring by coherence-community.

the class CacheAbstractionWithPrefixTests method testCachePrefix.

@Test
public void testCachePrefix() {
    final Cache cache = this.cacheManager.getCache("foo");
    final CoherenceCache coherenceCache = (CoherenceCache) cache;
    assertThat(coherenceCache.getCacheConfiguration().getTimeToLive()).isEqualTo(Duration.ZERO);
    assertThat(coherenceCache.getCacheConfiguration().getCacheNamePrefix()).isEqualTo("FooTesting_");
    assertThat(coherenceCache.getCacheConfiguration().isUseCacheNamePrefix()).isTrue();
    cache.put("fookey", "foovalue");
    final NamedCache<String, String> nativeFooCache = this.session.getCache("foo");
    assertThat(nativeFooCache.size()).isZero();
    final NamedCache<String, String> nativeFooCacheWithPrefix = this.session.getCache("FooTesting_foo");
    assertThat(nativeFooCacheWithPrefix.size()).isOne();
    assertThat(nativeFooCacheWithPrefix.get("fookey")).isEqualTo("foovalue");
}
Also used : CoherenceCache(com.oracle.coherence.spring.cache.CoherenceCache) Cache(org.springframework.cache.Cache) CoherenceCache(com.oracle.coherence.spring.cache.CoherenceCache) NamedCache(com.tangosol.net.NamedCache) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 2 with CoherenceCache

use of com.oracle.coherence.spring.cache.CoherenceCache in project coherence-spring by coherence-community.

the class CacheAbstractionTests method testCacheExpiration.

@Test
public void testCacheExpiration() {
    final Cache cache = this.cacheManager.getCache("foo");
    final CoherenceCache coherenceCache = (CoherenceCache) cache;
    assertThat(coherenceCache.getCacheConfiguration().getTimeToLive()).isEqualTo(Duration.ofMillis(1000));
    cache.put("fookey", "foovalue");
    assertThat(cache.get("fookey").get()).isEqualTo("foovalue");
    await().atMost(5, TimeUnit.SECONDS).untilAsserted(() -> assertThat(cache.get("fookey")).isNull());
}
Also used : CoherenceCache(com.oracle.coherence.spring.cache.CoherenceCache) Cache(org.springframework.cache.Cache) CoherenceCache(com.oracle.coherence.spring.cache.CoherenceCache) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

CoherenceCache (com.oracle.coherence.spring.cache.CoherenceCache)2 Test (org.junit.jupiter.api.Test)2 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)2 Cache (org.springframework.cache.Cache)2 NamedCache (com.tangosol.net.NamedCache)1