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");
}
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());
}
Aggregations