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


Java UtilCache.clearCache方法代码示例

本文整理汇总了Java中org.ofbiz.base.util.cache.UtilCache.clearCache方法的典型用法代码示例。如果您正苦于以下问题:Java UtilCache.clearCache方法的具体用法?Java UtilCache.clearCache怎么用?Java UtilCache.clearCache使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.ofbiz.base.util.cache.UtilCache的用法示例。


在下文中一共展示了UtilCache.clearCache方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: remove

import org.ofbiz.base.util.cache.UtilCache; //导入方法依赖的package包/类
public GenericValue remove(GenericPK pk) {
    UtilCache<GenericPK, GenericValue> entityCache = getCache(pk.getEntityName());
    if (Debug.verboseOn()) Debug.logVerbose("Removing from EntityCache with PK [" + pk + "], will remove from this cache: " + (entityCache == null ? "[No cache found to remove from]" : entityCache.getName()), module);
    if (entityCache == null) return null;
    GenericValue retVal = entityCache.remove(pk);
    ModelEntity model = pk.getModelEntity();
    if (model != null) {
        Iterator<String> it = model.getViewConvertorsIterator();
        while (it.hasNext()) {
            String targetEntityName = it.next();
            UtilCache.clearCache(getCacheName(targetEntityName));
        }
    }
    if (Debug.verboseOn()) Debug.logVerbose("Removing from EntityCache with PK [" + pk + "], found this in the cache: " + retVal, module);
    return retVal;
}
 
开发者ID:ilscipio,项目名称:scipio-erp,代码行数:17,代码来源:EntityCache.java

示例2: clearFileCaches

import org.ofbiz.base.util.cache.UtilCache; //导入方法依赖的package包/类
/**
 * Clears the system cache for location
 * 
 * @param dctx The DispatchContext that this service is operating in
 * @param context Map containing the input parameters
 * @return Map with the result of the service, the output parameters
 */
public static Map<String, Object> clearFileCaches(DispatchContext dctx, Map<String, ?> context) {
    try {
        if(UtilMisc.booleanValue(UtilProperties.getPropertyValue("cache", "cache.fileupdate.enable","true"), true)){
            String cacheName = (String) context.get("cacheName");
            String fileType = (String) context.get("fileType");
            String fileLocation = (String) context.get("fileLocation");
            UtilCache.clearCache(cacheName);            
            return ServiceUtil.returnSuccess("Cache cleared for "+cacheName);
        }else{
            return ServiceUtil.returnSuccess("Cache-Lock set. Cache not cleared");
        }
    }
    catch(Exception e) {
        final String errorMsg = "Exception triggering File Event";
        Debug.logError(e, errorMsg, module);
        return ServiceUtil.returnError(errorMsg + ": " + e.getMessage());
    }
}
 
开发者ID:ilscipio,项目名称:scipio-erp,代码行数:26,代码来源:CommonServices.java

示例3: remove

import org.ofbiz.base.util.cache.UtilCache; //导入方法依赖的package包/类
/**
 * Removes all condition caches that include the specified entity.
 */
public void remove(GenericEntity entity) {
    UtilCache.clearCache(getCacheName(entity.getEntityName()));
    ModelEntity model = entity.getModelEntity();
    if (model != null) {
        Iterator<String> it = model.getViewConvertorsIterator();
        while (it.hasNext()) {
            String targetEntityName = it.next();
            UtilCache.clearCache(getCacheName(targetEntityName));
        }
    }
}
 
开发者ID:ilscipio,项目名称:scipio-erp,代码行数:15,代码来源:AbstractEntityConditionCache.java

示例4: remove

import org.ofbiz.base.util.cache.UtilCache; //导入方法依赖的package包/类
public void remove(String entityName) {
    UtilCache.clearCache(getCacheName(entityName));
}
 
开发者ID:ilscipio,项目名称:scipio-erp,代码行数:4,代码来源:AbstractCache.java

示例5: basicTest

import org.ofbiz.base.util.cache.UtilCache; //导入方法依赖的package包/类
private static void basicTest(UtilCache<String, String> cache) throws Exception {
    Listener<String, String> gotListener = createListener(cache);
    Listener<String, String> wantedListener = new Listener<String, String>();
    for (int i = 0; i < 2; i++) {
        assertTrue("UtilCacheTable.keySet", UtilCache.getUtilCacheTableKeySet().contains(cache.getName()));
        assertSame("UtilCache.findCache", cache, UtilCache.findCache(cache.getName()));
        assertSame("UtilCache.getOrCreateUtilCache", cache, UtilCache.getOrCreateUtilCache(cache.getName(), cache.getSizeLimit(), cache.getMaxInMemory(), cache.getExpireTime(), cache.getUseSoftReference(), cache.getUseFileSystemStore()));

        assertNoSingleKey(cache, "one");
        long origByteSize = cache.getSizeInBytes();

        wantedListener.noteKeyAddition(cache, null, "null");
        assertNull("put", cache.put(null, "null"));
        assertHasSingleKey(cache, null, "null");
        long nullByteSize = cache.getSizeInBytes();
        assertThat(nullByteSize, greaterThan(origByteSize));

        wantedListener.noteKeyRemoval(cache, null, "null");
        assertEquals("remove", "null", cache.remove(null));
        assertNoSingleKey(cache, null);

        wantedListener.noteKeyAddition(cache, "one", "uno");
        assertNull("put", cache.put("one", "uno"));
        assertHasSingleKey(cache, "one", "uno");
        long unoByteSize = cache.getSizeInBytes();
        assertThat(unoByteSize, greaterThan(origByteSize));

        wantedListener.noteKeyUpdate(cache, "one", "single", "uno");
        assertEquals("replace", "uno", cache.put("one", "single"));
        assertHasSingleKey(cache, "one", "single");
        long singleByteSize = cache.getSizeInBytes();
        assertThat(singleByteSize, greaterThan(origByteSize));
        assertThat(singleByteSize, greaterThan(unoByteSize));

        wantedListener.noteKeyRemoval(cache, "one", "single");
        assertEquals("remove", "single", cache.remove("one"));
        assertNoSingleKey(cache, "one");
        assertEquals("byteSize", origByteSize, cache.getSizeInBytes());

        wantedListener.noteKeyAddition(cache, "one", "uno");
        assertNull("put", cache.put("one", "uno"));
        assertHasSingleKey(cache, "one", "uno");

        wantedListener.noteKeyUpdate(cache, "one", "only", "uno");
        assertEquals("replace", "uno", cache.put("one", "only"));
        assertHasSingleKey(cache, "one", "only");

        wantedListener.noteKeyRemoval(cache, "one", "only");
        cache.erase();
        assertNoSingleKey(cache, "one");
        assertEquals("byteSize", origByteSize, cache.getSizeInBytes());

        cache.setExpireTime(100);
        wantedListener.noteKeyAddition(cache, "one", "uno");
        assertNull("put", cache.put("one", "uno"));
        assertHasSingleKey(cache, "one", "uno");

        wantedListener.noteKeyRemoval(cache, "one", "uno");
        Thread.sleep(200);
        assertNoSingleKey(cache, "one");
    }

    assertEquals("get-miss", 10, cache.getMissCountNotFound());
    assertEquals("get-miss-total", 10, cache.getMissCountTotal());
    assertEquals("get-hit", 12, cache.getHitCount());
    assertEquals("remove-hit", 6, cache.getRemoveHitCount());
    assertEquals("remove-miss", 10, cache.getRemoveMissCount());
    cache.removeListener(gotListener);
    assertEquals("listener", wantedListener, gotListener);
    UtilCache.clearCache(cache.getName());
    UtilCache.clearCache(":::" + cache.getName());
}
 
开发者ID:ilscipio,项目名称:scipio-erp,代码行数:73,代码来源:UtilCacheTests.java

示例6: remove

import org.ofbiz.base.util.cache.UtilCache; //导入方法依赖的package包/类
public void remove(String widgetName) {
    UtilCache.clearCache(getCacheName(widgetName));
}
 
开发者ID:ilscipio,项目名称:scipio-erp,代码行数:4,代码来源:AbstractCache.java


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