本文整理汇总了Java中org.ofbiz.base.util.cache.UtilCache.get方法的典型用法代码示例。如果您正苦于以下问题:Java UtilCache.get方法的具体用法?Java UtilCache.get怎么用?Java UtilCache.get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.ofbiz.base.util.cache.UtilCache
的用法示例。
在下文中一共展示了UtilCache.get方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getTemplate
import org.ofbiz.base.util.cache.UtilCache; //导入方法依赖的package包/类
/**
* Gets a Template instance from the template cache. If the Template instance isn't
* found in the cache, then one will be created.
* <p>
* SCIPIO: 2017-02-21: May now pass cache null to bypass caching.
*/
public static Template getTemplate(String templateLocation, UtilCache<String, Template> cache, Configuration config) throws TemplateException, IOException {
Template template = (cache != null) ? cache.get(templateLocation) : null;
if (template == null) {
// only make the reader if we need it, and then close it right after!
Reader templateReader = makeReader(templateLocation);
try {
template = new Template(templateLocation, templateReader, config);
} finally { // SCIPIO: added finally
templateReader.close();
}
if (cache != null) {
template = cache.putIfAbsentAndGet(templateLocation, template);
}
}
return template;
}
示例2: getTemplateFromString
import org.ofbiz.base.util.cache.UtilCache; //导入方法依赖的package包/类
/**
* SCIPIO: Gets template from string out of custom cache (new).
* 2017-02-21: May now pass cache null to bypass caching.
*/
public static Template getTemplateFromString(String templateString, String templateKey, String templateName, UtilCache<String, Template> cache, Configuration config) throws TemplateException, IOException {
Template template = (cache != null) ? cache.get(templateKey) : null;
if (template == null) {
Reader templateReader = new StringReader(templateString);
try {
template = new Template(templateName, templateReader, config);
} finally {
templateReader.close();
}
if (cache != null) {
template = cache.putIfAbsentAndGet(templateKey, template);
}
}
return template;
}
示例3: getOrCreateConditionCache
import org.ofbiz.base.util.cache.UtilCache; //导入方法依赖的package包/类
protected Map<K, V> getOrCreateConditionCache(String entityName, EntityCondition condition) {
UtilCache<EntityCondition, ConcurrentMap<K, V>> utilCache = getOrCreateCache(entityName);
EntityCondition conditionKey = getConditionKey(condition);
ConcurrentMap<K, V> conditionCache = utilCache.get(conditionKey);
if (conditionCache == null) {
conditionCache = new ConcurrentHashMap<K, V>();
utilCache.put(conditionKey, conditionCache);
}
return conditionCache;
}
示例4: remove
import org.ofbiz.base.util.cache.UtilCache; //导入方法依赖的package包/类
public void remove(String entityName, EntityCondition condition) {
UtilCache<GenericPK, GenericValue> entityCache = getCache(entityName);
if (entityCache == null) return;
for (GenericPK pk: entityCache.getCacheLineKeys()) {
GenericValue entity = entityCache.get(pk);
if (entity == null) continue;
if (condition.entityMatches(entity)) entityCache.remove(pk);
}
}
示例5: getTemplate
import org.ofbiz.base.util.cache.UtilCache; //导入方法依赖的package包/类
public static Template getTemplate(String templateLocation, UtilCache<String, Template> cache, Configuration config) throws TemplateException, IOException {
Template template = cache.get(templateLocation);
if (template == null) {
// only make the reader if we need it, and then close it right after!
Reader templateReader = makeReader(templateLocation);
template = new Template(templateLocation, templateReader, config);
templateReader.close();
template = cache.putIfAbsentAndGet(templateLocation, template);
}
return template;
}
示例6: getConditionCache
import org.ofbiz.base.util.cache.UtilCache; //导入方法依赖的package包/类
protected ConcurrentMap<K, V> getConditionCache(String entityName, EntityCondition condition) {
UtilCache<EntityCondition, ConcurrentMap<K, V>> cache = getCache(entityName);
if (cache == null) return null;
return cache.get(getConditionKey(condition));
}
示例7: get
import org.ofbiz.base.util.cache.UtilCache; //导入方法依赖的package包/类
public GenericValue get(GenericPK pk) {
UtilCache<GenericPK, GenericValue> entityCache = getCache(pk.getEntityName());
if (entityCache == null) return null;
return entityCache.get(pk);
}
示例8: get
import org.ofbiz.base.util.cache.UtilCache; //导入方法依赖的package包/类
public GenericWidgetOutput get(String screenName, WidgetContextCacheKey wcck) {
UtilCache<WidgetContextCacheKey,GenericWidgetOutput> screenCache = getCache(screenName);
if (screenCache == null) return null;
return screenCache.get(wcck);
}