本文整理汇总了Java中javax.cache.expiry.AccessedExpiryPolicy类的典型用法代码示例。如果您正苦于以下问题:Java AccessedExpiryPolicy类的具体用法?Java AccessedExpiryPolicy怎么用?Java AccessedExpiryPolicy使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AccessedExpiryPolicy类属于javax.cache.expiry包,在下文中一共展示了AccessedExpiryPolicy类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: configure
import javax.cache.expiry.AccessedExpiryPolicy; //导入依赖的package包/类
@Override
public void configure(Binder binder) {
//programmatically configured cache
Configuration<String, String> programmaticCache =
new MutableConfiguration<String, String>()
.setTypes(String.class, String.class)
.setExpiryPolicyFactory(AccessedExpiryPolicy.factoryOf(Duration.ONE_HOUR))
.setReadThrough(true)
.setWriteThrough(true)
.addCacheEntryListenerConfiguration(new MyCache2EntryListenerConfiguration());
//contribute the cache into BQ
JCacheModule.extend(binder).setConfiguration("myCache2", programmaticCache);
BQCoreModule.extend(binder).addCommand(DemoHazelcastCommand.class);
}
开发者ID:bootique-examples,项目名称:bootique-jcache-demo,代码行数:18,代码来源:Application.java
示例2: cacheExposesMetrics
import javax.cache.expiry.AccessedExpiryPolicy; //导入依赖的package包/类
@ParameterizedTest
@MethodSource("cachingProviders")
void cacheExposesMetrics(CachingProvider provider) {
CacheManager cacheManager = provider.getCacheManager();
MutableConfiguration<Integer, String> configuration = new MutableConfiguration<>();
configuration.setTypes(Integer.class, String.class)
.setExpiryPolicyFactory(AccessedExpiryPolicy.factoryOf(ONE_HOUR))
.setStatisticsEnabled(true);
Cache<Integer, String> cache = cacheManager.createCache("a", configuration);
cache.put(1, "test");
MeterRegistry registry = new SimpleMeterRegistry();
JCacheMetrics.monitor(registry, cache, "jcache", emptyList());
assertThat(registry.mustFind("jcache.puts").tags("name", "a").gauge().value()).isEqualTo(1.0);
}
开发者ID:micrometer-metrics,项目名称:micrometer,代码行数:19,代码来源:JCacheMetricsTest.java
示例3: createCache
import javax.cache.expiry.AccessedExpiryPolicy; //导入依赖的package包/类
/**
* Create a new cache from the given cache manager.
*
* @param cacheName Name of the cache.
* @param keyClass Type of the key class.
* @param valueClass Type of the value class.
* @param defaultExpiryTime Cache expire time in minutes.
* @param cacheConfigMap Cache config map.
* @param cacheManager Cache manager to use to create the cache.
* @param <K> Type of the Key.
* @param <V> Type of the Value.
* @return Created cache.
*/
public static <K, V> Cache<K, V> createCache(String cacheName, Class<K> keyClass, Class<V> valueClass,
int defaultExpiryTime, Map<String, CacheConfig> cacheConfigMap,
CacheManager cacheManager) {
Duration cacheExpiry = new Duration(TimeUnit.MINUTES, getExpireTime(cacheConfigMap, cacheName,
defaultExpiryTime));
boolean isStatisticsEnabled = false;
if (cacheConfigMap.get(cacheName) != null) {
isStatisticsEnabled = cacheConfigMap.get(cacheName).isStatisticsEnabled();
}
MutableConfiguration<K, V> configuration = new MutableConfiguration<>();
configuration.setStoreByValue(false)
.setTypes(keyClass, valueClass)
.setExpiryPolicyFactory(AccessedExpiryPolicy.factoryOf(cacheExpiry))
.setStatisticsEnabled(isStatisticsEnabled);
return cacheManager.createCache(cacheName, configuration);
}
开发者ID:wso2,项目名称:carbon-identity-mgt,代码行数:35,代码来源:CacheHelper.java
示例4: before
import javax.cache.expiry.AccessedExpiryPolicy; //导入依赖的package包/类
@BeforeClass
public static void before() throws Exception {
dataModel = Converters.toDataModel(new XSSFWorkbook(pathDataModel));
CacheManager cacheManager = Caching.getCachingProvider().getCacheManager();
MutableConfiguration config = new MutableConfiguration();
config.setStoreByValue(false)
.setExpiryPolicyFactory(AccessedExpiryPolicy.factoryOf(Duration.ETERNAL))
.setStatisticsEnabled(false);
cacheManager.createCache(CacheBasedDataSetAccessor.DATA_SET_TO_ID_CACHE_NAME, config.setTypes(IDataModelId.class, IDataSet.class));
cacheManager.createCache(CacheBasedDataSetAccessor.DATA_SET_TO_NAME_CACHE_NAME, config.setTypes(String.class, IDataSet.class));
ExternalServices.INSTANCE.setDataSetAccessor(new CacheBasedDataSetAccessor());
expectedValues = new HashMap<>();
SpreadsheetEvaluator evaluator = new SpreadsheetEvaluator(dataModel);
for (int i = expectedRowStart; i <= expectedRowEnd; i++) {
ICellValue value = evaluator.evaluate(A1Address.fromA1Address(expectedColumn + i)).getResult();
expectedValues.put(expectedColumn + i, value.get());
}
}
开发者ID:DataArt,项目名称:CalculationEngine,代码行数:25,代码来源:Validate_Function_Test.java
示例5: JCacheTemplateCache
import javax.cache.expiry.AccessedExpiryPolicy; //导入依赖的package包/类
public JCacheTemplateCache() {
Iterator<CachingProvider> cachingProviders = Caching.getCachingProviders().iterator();
if (cachingProviders.hasNext()) {
CachingProvider cachingProvider = cachingProviders.next();
CacheManager cacheManager = cachingProvider.getCacheManager();
Configuration<String, Template> config = new MutableConfiguration<String, Template>()
.setTypes(String.class, Template.class)
.setExpiryPolicyFactory(AccessedExpiryPolicy.factoryOf(new Duration(TimeUnit.MINUTES, 5)));
Cache<String, Template> cache = cacheManager.getCache("TemplateCache", String.class, Template.class);
if (cache == null) {
this.cache = cacheManager.createCache("TemplateCache", config);
} else {
this.cache = cache;
}
} else {
this.cache = null; // to keep compatibility with 0.1.0, but ugly
}
}
开发者ID:kawasima,项目名称:moshas,代码行数:19,代码来源:JCacheTemplateCache.java
示例6: testParametersInURI
import javax.cache.expiry.AccessedExpiryPolicy; //导入依赖的package包/类
@Test
public void testParametersInURI() throws URISyntaxException {
CachingProvider cachingProvider = Caching.getCachingProvider();
Properties p = new Properties();
try (CacheManager cacheManager = cachingProvider.getCacheManager(new URI(cachingProvider.getDefaultURI() + "?secret=testsecret"), cachingProvider.getDefaultClassLoader(), p)) {
MutableConfiguration<String, Integer> config
= new MutableConfiguration<String, Integer>()
.setTypes(String.class, Integer.class)
.setExpiryPolicyFactory(AccessedExpiryPolicy.factoryOf(ONE_HOUR))
.setStatisticsEnabled(true);
Cache<String, Integer> cache = cacheManager.createCache("simpleCache", config);
BlazingCacheManager manager = cacheManager.unwrap(BlazingCacheManager.class);
assertEquals("testsecret", manager.getProperties().get("blazingcache.secret"));
String key = "key";
Integer value1 = 1;
cache.put("key", value1);
Integer value2 = cache.get(key);
assertEquals(value1, value2);
cache.remove(key);
assertNull(cache.get(key));
}
}
开发者ID:diennea,项目名称:blazingcache,代码行数:26,代码来源:ParametersInURITest.java
示例7: testJSRExample1
import javax.cache.expiry.AccessedExpiryPolicy; //导入依赖的package包/类
@Test
public void testJSRExample1() {
CachingProvider cachingProvider = Caching.getCachingProvider();
Properties p = new Properties();
try (CacheManager cacheManager = cachingProvider.getCacheManager(cachingProvider.getDefaultURI(), cachingProvider.getDefaultClassLoader(), p)) {
MutableConfiguration<String, Integer> config
= new MutableConfiguration<String, Integer>()
.setTypes(String.class, Integer.class)
.setExpiryPolicyFactory(AccessedExpiryPolicy.factoryOf(ONE_HOUR))
.setStatisticsEnabled(true);
Cache<String, Integer> cache = cacheManager.createCache("simpleCache", config);
String key = "key";
Integer value1 = 1;
cache.put("key", value1);
Integer value2 = cache.get(key);
assertEquals(value1, value2);
cache.remove(key);
assertNull(cache.get(key));
}
}
开发者ID:diennea,项目名称:blazingcache,代码行数:24,代码来源:JSRExamplesTest.java
示例8: main
import javax.cache.expiry.AccessedExpiryPolicy; //导入依赖的package包/类
public static void main(String[] args) {
CachingProvider cachingProvider = Caching.getCachingProvider();
CacheManager cacheManager = cachingProvider.getCacheManager();
Cache<String, User> cache = cacheManager.getCache("Users", String.class, User.class);
cache.put("Bob", new User("Bob", "[email protected]"));
User user = cache.get("Bob");
MutableConfiguration<String, User> config =
new MutableConfiguration<String, User>();
config.setTypes(String.class, User.class)
.setStatisticsEnabled(true)
.setStoreByValue(true)
.setExpiryPolicyFactory(AccessedExpiryPolicy.
factoryOf(Duration.ONE_MINUTE));
cacheManager.createCache("Orders", config);
}
开发者ID:kasunbg,项目名称:jcache-samples,代码行数:21,代码来源:JCacheTest.java
示例9: testCreateConfiguration
import javax.cache.expiry.AccessedExpiryPolicy; //导入依赖的package包/类
@Test
public void testCreateConfiguration() throws Exception {
CompleteConfiguration<String, List> configuration = service.createConfiguration(
String.class, List.class, ImmutableMap.<String, String>builder().
put( Constants.CONFIG_TTL, String.valueOf( 60 * 2 ) ).
put( Constants.CONFIG_TTL_RESET, Constants.ExpiryFunction.ACCESS.name() ).
put( Constants.CONFIG_STORE_BY_VALUE, "false" ).
build()
);
assertThat( configuration.getKeyType(), Matchers.<Class>equalTo( String.class ) );
assertThat( configuration.getValueType(), Matchers.<Class>equalTo( List.class ) );
assertFalse( configuration.isStoreByValue() );
ExpiryPolicy expiryPolicy = configuration.getExpiryPolicyFactory().create();
assertThat( expiryPolicy, instanceOf( AccessedExpiryPolicy.class ) );
assertThat( expiryPolicy.getExpiryForAccess(), equalTo( new Duration( TimeUnit.MINUTES, 2 ) ) );
assertThat( expiryPolicy.getExpiryForUpdate(), nullValue() );
}
开发者ID:pentaho,项目名称:pentaho-osgi-bundles,代码行数:20,代码来源:AbstractCacheProvidingServiceTest.java
示例10: testCacheExpired
import javax.cache.expiry.AccessedExpiryPolicy; //导入依赖的package包/类
@Test
public void testCacheExpired() throws Exception {
Configuration<String, String> configuration =
new MutableConfiguration<String, String>()
.setExpiryPolicyFactory(AccessedExpiryPolicy.factoryOf(new Duration(TimeUnit.SECONDS, 3)));
try (CachingProvider provider = Caching.getCachingProvider();
CacheManager manager = provider.getCacheManager();
Cache<String, String> cache = manager.createCache("testCache",
configuration)) {
cache.put("key1", "value1");
cache.put("key2", "value2");
TimeUnit.SECONDS.sleep(1);
cache.get("key2");
TimeUnit.SECONDS.sleep(2);
assertThat(cache.get("key1")).isNull();
assertThat(cache.get("key2")).isEqualTo("value2");
}
}
开发者ID:kazuhira-r,项目名称:hazelcast-examples,代码行数:24,代码来源:HazelcastJCacheTest.java
示例11: testCreateCacheWithUnsupportedAccessedExpiryPolicy
import javax.cache.expiry.AccessedExpiryPolicy; //导入依赖的package包/类
@Test(expected = UnsupportedOperationException.class)
public void testCreateCacheWithUnsupportedAccessedExpiryPolicy()
{
CacheManager cacheManager = cachingProvider.getCacheManager();
MutableConfiguration<Number, Number> configuration = new MutableConfiguration<>();
configuration.setStoreByValue(false);
configuration.setExpiryPolicyFactory(AccessedExpiryPolicy.factoryOf(Duration.ZERO));
cacheManager.createCache("cache", configuration);
}
开发者ID:ocafebabe,项目名称:guava-jcache,代码行数:13,代码来源:GuavaCacheManagerTest.java
示例12: before
import javax.cache.expiry.AccessedExpiryPolicy; //导入依赖的package包/类
@BeforeClass
public static void before() throws Exception {
dataModel = Converters.toDataModel(new XSSFWorkbook(pathDataModel));
CacheManager cacheManager = Caching.getCachingProvider().getCacheManager();
MutableConfiguration config = new MutableConfiguration();
config.setStoreByValue(false)
.setExpiryPolicyFactory(AccessedExpiryPolicy.factoryOf(Duration.ETERNAL))
.setStatisticsEnabled(false);
cacheManager.createCache(CacheBasedDataModelAccessor.DATA_MODEL_TO_ID_CACHE_NAME, config.setTypes(IDataModelId.class, IDataModel.class));
cacheManager.createCache(CacheBasedDataModelAccessor.DATA_MODEL_TO_NAME_CACHE_NAME, config.setTypes(String.class, IDataModel.class));
cacheManager.createCache(CacheBasedMetaFunctionAccessor.META_FUNCTIONS_CACHE_NAME, config.setTypes(String.class, FunctionMeta.class));
DataModelAccessor dataModelAccessor = new CacheBasedDataModelAccessor();
MetaFunctionAccessor metaFunctionAccessor = new CacheBasedMetaFunctionAccessor();
globalContext = new EvaluationContext();
globalContext.set(DataModelAccessor.class, dataModelAccessor);
globalContext.set(MetaFunctionAccessor.class, metaFunctionAccessor);
dataModelAccessor.add(dataModel); //execution model
Map<DefineFunctionMeta, IDataModel> defineModels = Converters.toMetaFunctions(new XSSFWorkbook(pathDataModel), DefineFunctionMeta.class);
defineModels.forEach((k, v) -> {
metaFunctionAccessor.add(k); //defein meta info with link to DataModel
dataModelAccessor.add(v); //define model
});
}
开发者ID:DataArt,项目名称:CalculationEngine,代码行数:31,代码来源:FuncexecNoSingleton_Test.java
示例13: before
import javax.cache.expiry.AccessedExpiryPolicy; //导入依赖的package包/类
@BeforeClass
public static void before() throws Exception {
dataModel = Converters.toDataModel(new XSSFWorkbook(pathDataModel));
CacheManager cacheManager = Caching.getCachingProvider().getCacheManager();
MutableConfiguration config = new MutableConfiguration();
config.setStoreByValue(false)
.setExpiryPolicyFactory(AccessedExpiryPolicy.factoryOf(Duration.ETERNAL))
.setStatisticsEnabled(false);
cacheManager.createCache(CacheBasedDataModelAccessor.DATA_MODEL_TO_ID_CACHE_NAME, config.setTypes(IDataModelId.class, IDataModel.class));
cacheManager.createCache(CacheBasedDataModelAccessor.DATA_MODEL_TO_NAME_CACHE_NAME, config.setTypes(String.class, IDataModel.class));
cacheManager.createCache(CacheBasedMetaFunctionAccessor.META_FUNCTIONS_CACHE_NAME, config.setTypes(String.class, FunctionMeta.class));
final ExternalServices external = ExternalServices.INSTANCE;
DataModelAccessor dataModelAccessor = new CacheBasedDataModelAccessor();
MetaFunctionAccessor metaFunctionAccessor = new CacheBasedMetaFunctionAccessor();
external.setDataModelAccessor(dataModelAccessor);
external.setMetaFunctionAccessor(metaFunctionAccessor);
dataModelAccessor.add(dataModel); //execution model
Map<DefineFunctionMeta, IDataModel> defineModels = Converters.toMetaFunctions(new XSSFWorkbook(pathDataModel), DefineFunctionMeta.class);
defineModels.forEach((k, v) -> {
metaFunctionAccessor.add(k); //defein meta info with link to DataModel
dataModelAccessor.add(v); //define model
});
expectedValues = new HashMap<>();
evaluator = new SpreadsheetEvaluator(dataModel);
for (int i = expectedRowStart; i <= expectedRowEnd; i++) {
ICellValue value = evaluator.evaluate(A1Address.fromA1Address(expectedColumn + i)).getResult();
expectedValues.put(expectedColumn + i, value.get());
}
}
开发者ID:DataArt,项目名称:CalculationEngine,代码行数:40,代码来源:Funcexec_Test.java
示例14: before
import javax.cache.expiry.AccessedExpiryPolicy; //导入依赖的package包/类
@BeforeClass
public static void before() throws Exception {
dataModel = Converters.toDataModel(new XSSFWorkbook(pathDataModel));
CacheManager cacheManager = Caching.getCachingProvider().getCacheManager();
MutableConfiguration config = new MutableConfiguration();
config.setStoreByValue(false)
.setExpiryPolicyFactory(AccessedExpiryPolicy.factoryOf(Duration.ETERNAL))
.setStatisticsEnabled(false);
cacheManager.createCache(CacheBasedDataSetAccessor.DATA_SET_TO_ID_CACHE_NAME, config.setTypes(IDataModelId.class, IDataSet.class));
cacheManager.createCache(CacheBasedDataSetAccessor.DATA_SET_TO_NAME_CACHE_NAME, config.setTypes(String.class, IDataSet.class));
cacheManager.createCache(CacheBasedDataModelAccessor.DATA_MODEL_TO_ID_CACHE_NAME, config.setTypes(IDataModelId.class, IDataModel.class));
cacheManager.createCache(CacheBasedDataModelAccessor.DATA_MODEL_TO_NAME_CACHE_NAME, config.setTypes(String.class, IDataModel.class));
cacheManager.createCache(CacheBasedMetaFunctionAccessor.META_FUNCTIONS_CACHE_NAME, config.setTypes(String.class, FunctionMeta.class));
DataModelAccessor dataModelAccessor = new CacheBasedDataModelAccessor();
MetaFunctionAccessor metaFunctionAccessor = new CacheBasedMetaFunctionAccessor();
dataModelAccessor.add(dataModel); //execution model
Map<DefineFunctionMeta, IDataModel> defineModels = new HashMap<>();
defineModels.putAll(Converters.toMetaFunctions(new XSSFWorkbook(pathDataModel), DefineFunctionMeta.class));
defineModels.putAll(Converters.toMetaFunctions(new XSSFWorkbook(pathFuncexecLevel1), DefineFunctionMeta.class));
defineModels.putAll(Converters.toMetaFunctions(new XSSFWorkbook(pathFuncexecLevel2), DefineFunctionMeta.class));
defineModels.forEach((k, v) -> {
metaFunctionAccessor.add(k); //defein meta info with link to DataModel
dataModelAccessor.add(v); //define model
});
ExternalServices.INSTANCE.setDataSetAccessor(new CacheBasedDataSetAccessor());
ExternalServices.INSTANCE.setDataModelAccessor(dataModelAccessor);
ExternalServices.INSTANCE.setMetaFunctionAccessor(metaFunctionAccessor);
}
开发者ID:DataArt,项目名称:CalculationEngine,代码行数:37,代码来源:ValidateWithFuncexec_Function_Test.java
示例15: before
import javax.cache.expiry.AccessedExpiryPolicy; //导入依赖的package包/类
@BeforeClass
public static void before() throws Exception {
dataModel = Converters.toDataModel(new XSSFWorkbook(pathDataModel));
CacheManager cacheManager = Caching.getCachingProvider().getCacheManager();
MutableConfiguration config = new MutableConfiguration();
config.setStoreByValue(false)
.setExpiryPolicyFactory(AccessedExpiryPolicy.factoryOf(Duration.ETERNAL))
.setStatisticsEnabled(false);
cacheManager.createCache(CacheBasedDataSetAccessor.DATA_SET_TO_ID_CACHE_NAME, config.setTypes(IDataModelId.class, IDataSet.class));
cacheManager.createCache(CacheBasedDataSetAccessor.DATA_SET_TO_NAME_CACHE_NAME, config.setTypes(String.class, IDataSet.class));
cacheManager.createCache(DataSetOptimisationsCache.DATA_SET_TO_LAZY_PARAMETERS, config.setTypes(ILazyDataSet.Parameters.class, IDataSet.class));
cacheManager.createCache(DataSetOptimisationsCache.DATA_SET_DS_LOOKUP_PARAMETERS, config.setTypes(DsLookupParameters.class, List.class));
final ExternalServices external = ExternalServices.INSTANCE;
DataSetAccessor dataSetStorage = new CacheBasedDataSetAccessor();
external.setDataSetAccessor(dataSetStorage);
external.setDataSetOptimisationsCache(new DataSetOptimisationsCache());
final IDataSet dataSet = Converters.toDataSet(new XSSFWorkbook(pathDataSet));
dataSetStorage.add(dataSet);
expectedValues = new HashMap<>();
evaluator = new SpreadsheetEvaluator(dataModel);
for (int i = expectedRowStart; i <= expectedRowEnd; i++) {
ICellValue value = evaluator.evaluate(A1Address.fromA1Address(expectedColumn + i)).getResult();
expectedValues.put(expectedColumn + i, value.get());
}
}
开发者ID:DataArt,项目名称:CalculationEngine,代码行数:35,代码来源:Monthly_Data_Query_Test.java
示例16: get
import javax.cache.expiry.AccessedExpiryPolicy; //导入依赖的package包/类
private static void get() {
System.setProperty("hazelcast.jcache.provider.type", "client");
CachingProvider cachingProvider = Caching.getCachingProvider();
CacheManager cacheManager = cachingProvider.getCacheManager();
//configure the cache
MutableConfiguration<String, String> config = new MutableConfiguration<String, String>();
config.setStoreByValue(true)
.setTypes(String.class, String.class)
.setExpiryPolicyFactory(AccessedExpiryPolicy.factoryOf(new Duration(TimeUnit.MILLISECONDS, 10 * 1000)))
.setStatisticsEnabled(false);
//create the cache
cacheManager.createCache("MY_CACHE", config);
//get the cache
Cache<String, String> cache = cacheManager.getCache("MY_CACHE", String.class, String.class);
String value = cache.get("theKey");
System.out.println(value);//prints 'Hello World'
for (int increment = 0; increment < 100; increment++) {
value = cache.get("key-" + increment);
System.out.print(value + " ");
}
}
开发者ID:kasunbg,项目名称:jcache-samples,代码行数:31,代码来源:JCacheGetter.java
示例17: put
import javax.cache.expiry.AccessedExpiryPolicy; //导入依赖的package包/类
private static void put() {
System.setProperty("hazelcast.jcache.provider.type", "server");
CachingProvider cachingProvider = Caching.getCachingProvider();
CacheManager cacheManager = cachingProvider.getCacheManager();
//configure the cache
MutableConfiguration<String, String> config = new MutableConfiguration<String, String>();
config.setStoreByValue(true)
.setTypes(String.class, String.class)
.setExpiryPolicyFactory(AccessedExpiryPolicy.factoryOf(Duration.FIVE_MINUTES))
.setStatisticsEnabled(true);
cacheManager.destroyCache("MY_CACHE");
//create the cache
cacheManager.createCache("MY_CACHE", config);
//get the cache
Cache<String, String> cache = cacheManager.getCache("MY_CACHE", String.class, String.class);
cache.put("theKey", "Hello World");
String value = cache.get("theKey");
System.out.println("echo cache.get('theKey') = " + value);//prints 'Hello World'
for (int increment = 0; increment < 100; increment++) {
cache.put("key-" + increment, "Hello World - " + increment);
}
System.out.println("End");
}
开发者ID:kasunbg,项目名称:jcache-samples,代码行数:33,代码来源:JCacheSetter.java
示例18: initCaches
import javax.cache.expiry.AccessedExpiryPolicy; //导入依赖的package包/类
public static void initCaches(IDataModel model, String excel) throws IOException, InterruptedException {
//prepare caches to be used as storages
CacheManager cacheManager = Caching.getCachingProvider().getCacheManager();
MutableConfiguration config = new MutableConfiguration();
//some cache configurations
config.setStoreByValue(false)
.setExpiryPolicyFactory(AccessedExpiryPolicy.factoryOf(Duration.ETERNAL))
.setStatisticsEnabled(false);
//create the caches for application
cacheManager.createCache(CacheBasedDataModelAccessor.DATA_MODEL_TO_ID_CACHE_NAME, config.setTypes(IDataModelId.class, IDataModel.class));
cacheManager.createCache(CacheBasedDataModelAccessor.DATA_MODEL_TO_NAME_CACHE_NAME, config.setTypes(String.class, IDataModel.class));
cacheManager.createCache(CacheBasedDataSetAccessor.DATA_SET_TO_ID_CACHE_NAME, config.setTypes(IDataModelId.class, IDataSet.class));
cacheManager.createCache(CacheBasedDataSetAccessor.DATA_SET_TO_NAME_CACHE_NAME, config.setTypes(String.class, IDataSet.class));
cacheManager.createCache(CacheBasedDataSourceHub.DATA_SOURCE_CACHE_NAME, config.setTypes(Object.class, DataSource.class));
cacheManager.createCache(CacheBasedMetaFunctionAccessor.META_FUNCTIONS_CACHE_NAME, config.setTypes(String.class, DefineFunctionMeta.class));
cacheManager.createCache(DataSetOptimisationsCache.DATA_SET_TO_LAZY_PARAMETERS, config.setTypes(ILazyDataSet.Parameters.class, IDataSet.class));
cacheManager.createCache(DataSetOptimisationsCache.DATA_SET_DS_LOOKUP_PARAMETERS, config.setTypes(DsLookupParameters.class, List.class));
final ExternalServices external = ExternalServices.INSTANCE;
DataModelAccessor dataModelStorage = new CacheBasedDataModelAccessor();
DataSetAccessor dataSetStorage = new CacheBasedDataSetAccessor();
DataSourceHub dataSourceHub = new CacheBasedDataSourceHub();
MetaFunctionAccessor attributeFunctionStorage = new CacheBasedMetaFunctionAccessor();
external.setDataModelAccessor(dataModelStorage);
external.setDataSetAccessor(dataSetStorage);
external.setDataSourceHub(dataSourceHub);
external.setMetaFunctionAccessor(attributeFunctionStorage);
external.setDataSetOptimisationsCache(new DataSetOptimisationsCache());
//if this model is a dataset also - put it to cache
try {
final IDataSet dataSet = Converters.toDataSet(new XSSFWorkbook(excel));
dataSetStorage.add(dataSet);
} catch (Exception e) {
System.out.println("This workbook is not a dataset itself.");
}
//add data model to storage
dataModelStorage.add(model);
//update all define functions based on data models in cache
// attributeFunctionStorage.refreshDefines(new HashSet<>(dataModelStorage.getAll().values()));
//add in memory sql data source
dataSourceHub.add(new TempSqlDataSource());
//add lazy sql dataset to storage
String sql = "SELECT * FROM creaditcards WHERE AGE = ? OR AGE = ? OR FIRSTNAME = '?'";
final ILazyDataSet sqlDataSet = new SqlDataSet("PersonsWithCreaditCard", sql);
dataSetStorage.add(sqlDataSet);
dataSetStorage.add(new SqlDataSet("AllSkills", "SELECT * FROM skills"));
dataSetStorage.add(new SqlDataSet("SkillsInCity", "SELECT * FROM skills WHERE CITY = '?'"));
dataSetStorage.add(new SqlDataSet("SkillsForQualification", "SELECT FirstName, LastName FROM skills WHERE Qualification = '?'"));
dataSetStorage.add(new SqlDataSet("LevelFromSkillsInCity", "SELECT Level FROM skills WHERE City = '?'"));
dataSetStorage.add(new SqlDataSet("SkillsForNotLevelOfEnglish", "SELECT * FROM skills WHERE LevelOfEnglish is not '?'"));
dataSetStorage.add(new SqlDataSet("SkillsForLevelOfEnglish", "SELECT * FROM skills WHERE LevelOfEnglish = '?'"));
dataSetStorage.add(new SqlDataSet("SkillsForLevel", "SELECT FirstName, LastName FROM skills WHERE Level = '?'"));
}
开发者ID:DataArt,项目名称:CalculationEngine,代码行数:65,代码来源:DemoUtil.java
示例19: before
import javax.cache.expiry.AccessedExpiryPolicy; //导入依赖的package包/类
@BeforeClass
public static void before() throws Exception {
dataModel = Converters.toDataModel(new XSSFWorkbook(pathDataModel));
CacheManager cacheManager = Caching.getCachingProvider().getCacheManager();
MutableConfiguration config = new MutableConfiguration();
config.setStoreByValue(false)
.setExpiryPolicyFactory(AccessedExpiryPolicy.factoryOf(Duration.ETERNAL))
.setStatisticsEnabled(false);
cacheManager.createCache(CacheBasedDataModelAccessor.DATA_MODEL_TO_ID_CACHE_NAME, config.setTypes(IDataModelId.class, IDataModel.class));
cacheManager.createCache(CacheBasedDataModelAccessor.DATA_MODEL_TO_NAME_CACHE_NAME, config.setTypes(String.class, IDataModel.class));
cacheManager.createCache(CacheBasedDataSetAccessor.DATA_SET_TO_ID_CACHE_NAME, config.setTypes(IDataModelId.class, IDataSet.class));
cacheManager.createCache(CacheBasedDataSetAccessor.DATA_SET_TO_NAME_CACHE_NAME, config.setTypes(String.class, IDataSet.class));
cacheManager.createCache(CacheBasedDataSourceHub.DATA_SOURCE_CACHE_NAME, config.setTypes(Object.class, DataSource.class));
cacheManager.createCache(DataSetOptimisationsCache.DATA_SET_TO_LAZY_PARAMETERS, config.setTypes(ILazyDataSet.Parameters.class, IDataSet.class));
cacheManager.createCache(DataSetOptimisationsCache.DATA_SET_DS_LOOKUP_PARAMETERS, config.setTypes(DsLookupParameters.class, List.class));
final ExternalServices external = ExternalServices.INSTANCE;
DataModelAccessor dataModelStorage = new CacheBasedDataModelAccessor();
DataSetAccessor dataSetStorage = new CacheBasedDataSetAccessor();
DataSourceHub dataSourceHub = new CacheBasedDataSourceHub();
MetaFunctionAccessor attributeFunctionStorage = new CacheBasedMetaFunctionAccessor();
external.setDataModelAccessor(dataModelStorage);
external.setDataSetAccessor(dataSetStorage);
external.setDataSourceHub(dataSourceHub);
external.setMetaFunctionAccessor(attributeFunctionStorage);
external.setDataSetOptimisationsCache(new DataSetOptimisationsCache());
dataSourceHub.add(new TempSqlDataSource());
dataSetStorage.add(new SqlDataSet("AllSkills", "SELECT * FROM skills"));
dataSetStorage.add(new SqlDataSet("SkillsInCity", "SELECT * FROM skills WHERE CITY = '?' OR CITY = '?'"));
dataSetStorage.add(new SqlDataSet("SkillsForQualification", "SELECT FirstName, LastName FROM skills WHERE Qualification = '?'"));
dataSetStorage.add(new SqlDataSet("SkillsForNotLevelOfEnglish", "SELECT * FROM skills WHERE LevelOfEnglish is not ?"));
dataSetStorage.add(new SqlDataSet("SkillsForLevelOfEnglish", "SELECT FirstName, LastName, Level FROM skills WHERE LevelOfEnglish in (?, ?, ?)"));
expectedValues = new HashMap<>();
evaluator = new SpreadsheetEvaluator(dataModel);
for (int i = expectedRowStart; i <= expectedRowEnd; i++) {
ICellValue value = evaluator.evaluate(A1Address.fromA1Address(expectedColumn + i)).getResult();
expectedValues.put(expectedColumn + i, value.get());
}
}
开发者ID:DataArt,项目名称:CalculationEngine,代码行数:49,代码来源:Skills_Sql_Table_Test.java
示例20: initExternalServices
import javax.cache.expiry.AccessedExpiryPolicy; //导入依赖的package包/类
public static void initExternalServices(IDataModel model) throws Exception {
final ExternalServices external = ExternalServices.INSTANCE;
//prepare caches to be used as storages
CacheManager cacheManager = Caching.getCachingProvider().getCacheManager();
MutableConfiguration config = new MutableConfiguration();
//some cache configurations
config.setStoreByValue(false)
.setExpiryPolicyFactory(AccessedExpiryPolicy.factoryOf(ONE_HOUR))
.setStatisticsEnabled(true);
//create the caches for application
cacheManager.createCache(CacheBasedDataModelAccessor.DATA_MODEL_TO_ID_CACHE_NAME, config.setTypes(IDataModelId.class, IDataModel.class));
cacheManager.createCache(CacheBasedDataModelAccessor.DATA_MODEL_TO_NAME_CACHE_NAME, config.setTypes(String.class, IDataModel.class));
cacheManager.createCache(CacheBasedDataSetAccessor.DATA_SET_TO_ID_CACHE_NAME, config.setTypes(IDataModelId.class, IDataSet.class));
cacheManager.createCache(CacheBasedDataSetAccessor.DATA_SET_TO_NAME_CACHE_NAME, config.setTypes(String.class, IDataSet.class));
cacheManager.createCache(CacheBasedDataSourceHub.DATA_SOURCE_CACHE_NAME, config.setTypes(Object.class, DataSource.class));
cacheManager.createCache(CacheBasedMetaFunctionAccessor.META_FUNCTIONS_CACHE_NAME, config.setTypes(String.class, FunctionMeta.class));
cacheManager.createCache(DataSetOptimisationsCache.DATA_SET_TO_LAZY_PARAMETERS, config.setTypes(ILazyDataSet.Parameters.class, IDataSet.class));
DataModelAccessor dataModelStorage = new CacheBasedDataModelAccessor();
DataSetAccessor dataSetStorage = new CacheBasedDataSetAccessor();
DataSourceHub dataSourceHub = new CacheBasedDataSourceHub();
MetaFunctionAccessor attributeFunctionStorage = new CacheBasedMetaFunctionAccessor();
external.setDataModelAccessor(dataModelStorage);
external.setDataSetAccessor(dataSetStorage);
external.setDataSourceHub(dataSourceHub);
external.setMetaFunctionAccessor(attributeFunctionStorage);
//add data model to storage
dataModelStorage.add(model);
//update all define functions based on data models in cache
Map<DefineFunctionMeta, IDataModel> defineModels = Converters.toMetaFunctions(model, DefineFunctionMeta.class);
defineModels.forEach((k, v) -> {
attributeFunctionStorage.add(k); //defein meta info with link to DataModel
dataModelStorage.add(v); //define model
});
}
开发者ID:DataArt,项目名称:CalculationEngine,代码行数:42,代码来源:GraphTestUtil.java
注:本文中的javax.cache.expiry.AccessedExpiryPolicy类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论