Java Code Examples for org.cache2k.Cache2kBuilder#toConfiguration()
The following examples show how to use
org.cache2k.Cache2kBuilder#toConfiguration() .
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: SpringCache2kCacheManager.java From cache2k with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") static SpringCache2kCache buildAndWrap(Cache2kBuilder<?, ?> builder) { org.cache2k.Cache nativeCache = builder.build(); Cache2kConfiguration<?,?> cfg = builder.toConfiguration(); boolean loaderPresent = cfg.getLoader() != null || cfg.getAdvancedLoader() != null; return loaderPresent ? new SpringLoadingCache2kCache(nativeCache) : new SpringCache2kCache(nativeCache); }
Example 2
Source File: IntegrationTest.java From cache2k with Apache License 2.0 | 5 votes |
@Test public void defaultAndIndividualIsApplied() { Cache2kBuilder<String, String> b = new Cache2kBuilder<String, String>(){}.name("IntegrationTest-defaultAndIndividualIsApplied"); Cache2kConfiguration<String, String> cfg = b.toConfiguration(); assertEquals(-1, cfg.getEntryCapacity()); assertEquals(5, cfg.getLoaderThreadCount()); assertEquals(-1, cfg.getExpireAfterWrite()); Cache<String, String> c = b.build(); assertEquals(-1, cfg.getEntryCapacity()); assertEquals(47000, cfg.getExpireAfterWrite()); c.close(); }
Example 3
Source File: IntegrationTest.java From cache2k with Apache License 2.0 | 5 votes |
@Test public void validateVariableExpansion() { Cache2kBuilder b = new Cache2kBuilder<String, String>() { } .manager(CacheManager.getInstance("all")) .name("jcache1"); Cache2kConfiguration cfg = b.toConfiguration(); Cache c = b.build(); assertEquals(1153, cfg.getEntryCapacity()); assertEquals(123000, cfg.getMaxRetryInterval()); c.close(); }
Example 4
Source File: XmlConfigurationTest.java From cache2k with Apache License 2.0 | 5 votes |
@Test public void sectionIsThere() { Cache2kBuilder<String, String> b = new Cache2kBuilder<String, String>(){} .manager(CacheManager.getInstance(MANAGER_NAME)) .name("withSection"); Cache2kConfiguration<String, String> cfg = b.toConfiguration(); Cache<String, String> c = b.build(); assertEquals("default is false", false, new JCacheConfiguration().isCopyAlwaysIfRequested()); assertNotNull("section present", cfg.getSections().getSection(JCacheConfiguration.class)); assertEquals("config applied", true, cfg.getSections().getSection(JCacheConfiguration.class).isCopyAlwaysIfRequested()); c.close(); }
Example 5
Source File: XmlConfigurationTest.java From cache2k with Apache License 2.0 | 5 votes |
@Test public void sectionIsThereViaStandardElementName() { Cache2kBuilder<String, String> b = new Cache2kBuilder<String, String>(){} .manager(CacheManager.getInstance(MANAGER_NAME)) .name("withJCacheSection"); Cache2kConfiguration<String, String> cfg = b.toConfiguration(); Cache<String, String> c = b.build(); assertEquals("default is false", false, new JCacheConfiguration().isCopyAlwaysIfRequested()); assertNotNull("section present", cfg.getSections().getSection(JCacheConfiguration.class)); assertEquals("config applied", true, cfg.getSections().getSection(JCacheConfiguration.class).isCopyAlwaysIfRequested()); c.close(); }