当前位置: 首页>>代码示例>>Java>>正文


Java UtilCache.get方法代码示例

本文整理汇总了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;
}
 
开发者ID:ilscipio,项目名称:scipio-erp,代码行数:23,代码来源:FreeMarkerWorker.java

示例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;
}
 
开发者ID:ilscipio,项目名称:scipio-erp,代码行数:20,代码来源:FreeMarkerWorker.java

示例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;
}
 
开发者ID:ilscipio,项目名称:scipio-erp,代码行数:11,代码来源:AbstractEntityConditionCache.java

示例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);
    }
}
 
开发者ID:ilscipio,项目名称:scipio-erp,代码行数:10,代码来源:EntityCache.java

示例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;
}
 
开发者ID:gildaslemoal,项目名称:elpi,代码行数:12,代码来源:FreeMarkerWorker.java

示例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));
}
 
开发者ID:ilscipio,项目名称:scipio-erp,代码行数:6,代码来源:AbstractEntityConditionCache.java

示例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);
}
 
开发者ID:ilscipio,项目名称:scipio-erp,代码行数:6,代码来源:EntityCache.java

示例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);
}
 
开发者ID:ilscipio,项目名称:scipio-erp,代码行数:6,代码来源:ScreenCache.java


注:本文中的org.ofbiz.base.util.cache.UtilCache.get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。