本文整理了Java中net.sf.ehcache.Cache.remove()
方法的一些代码示例,展示了Cache.remove()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Cache.remove()
方法的具体详情如下:
包路径:net.sf.ehcache.Cache
类名称:Cache
方法名:remove
[英]Removes an Element from the Cache. This also removes it from any stores it may be in.
Also notifies the CacheEventListener after the element was removed.
Synchronization is handled within the method.
Caches which use synchronous replication can throw RemoteCacheException here if the replication to the cluster fails. This exception should be caught in those circumstances.
[中]从缓存中删除元素。这也会将其从任何存储中删除。
还将在删除元素后通知CacheEventListener。
同步是在方法中处理的。
如果到群集的复制失败,则使用同步复制的缓存可以在此处引发RemoteCacheException。在这些情况下,应抓住这一例外。
代码示例来源:origin: ninjaframework/ninja
public void delete(String key) {
ehCache.remove(key);
}
代码示例来源:origin: shuzheng/zheng
/**
* 删除缓存记录
* @param cacheName
* @param key
* @return
*/
public static boolean remove(String cacheName, String key) {
Cache cache = getCache(cacheName);
if (null == cache) {
return false;
}
return cache.remove(key);
}
代码示例来源:origin: Dreampie/Resty
public void removeCache(String group, String key) {
if (cacheManager.getCache(group) != null) {
cacheManager.getCache(group).remove(key);
}
}
代码示例来源:origin: jfinal/jfinal
public static void remove(String cacheName, Object key) {
getOrAddCache(cacheName).remove(key);
}
代码示例来源:origin: javamelody/javamelody
private void clearCacheKey(String cacheId, String cacheKey) {
final List<CacheManager> allCacheManagers = CacheManager.ALL_CACHE_MANAGERS;
for (final CacheManager cacheManager : allCacheManagers) {
final Cache cache = cacheManager.getCache(cacheId);
if (cache != null) {
final boolean removed = cache.remove(cacheKey);
if (!removed) {
// if keys are not Strings, we have to find the initial key
for (final Object key : cache.getKeys()) {
if (key != null && key.toString().equals(cacheKey)) {
cache.remove(key);
break;
}
}
}
}
}
}
代码示例来源:origin: BroadleafCommerce/BroadleafCommerce
@Override
public boolean removeItemFromCacheByKey(String key) {
// Remove secure and non-secure instances of the structured content.
// Typically the structured content will be in one or the other if at all.
boolean successSecure = false;
boolean successNonSecure = false;
if (!StringUtils.isEmpty(key)) {
successSecure = getStructuredContentCache().remove(key + "-" + true);
successNonSecure = getStructuredContentCache().remove(key + "-" + false);
}
return successSecure || successNonSecure;
}
代码示例来源:origin: primefaces/primefaces
@Override
public void remove(String region, String key) {
Cache cacheRegion = getRegion(region);
cacheRegion.remove(key);
}
代码示例来源:origin: BroadleafCommerce/BroadleafCommerce
public static void clearCache() {
long threadId = Thread.currentThread().getId();
getCache().remove(threadId);
}
代码示例来源:origin: stylefeng/Guns
public static void remove(String cacheName, Object key) {
getOrAddCache(cacheName).remove(key);
}
代码示例来源:origin: BroadleafCommerce/BroadleafCommerce
@Override
public Boolean removeURLHandlerFromCache(String mapKey) {
Boolean success = Boolean.FALSE;
if (mapKey != null) {
Element e = getUrlHandlerCache().get(mapKey);
if (e != null && e.getObjectValue() != null) {
success = Boolean.valueOf(getUrlHandlerCache().remove(mapKey));
}
}
return success;
}
代码示例来源:origin: BroadleafCommerce/BroadleafCommerce
@Override
@SuppressWarnings("unchecked")
public Boolean removePageFromCache(String mapKey) {
Boolean success = null;
if (mapKey != null) {
Element e = getPageMapCache().get(mapKey);
if (e != null && e.getObjectValue() != null) {
List<String> keys = (List<String>) e.getObjectValue();
for (String k : keys) {
if (success == null) {
success = getPageCache().remove(k);
} else {
success = success && getPageCache().remove(k);
}
}
}
}
return success == null ? Boolean.FALSE : success;
}
代码示例来源:origin: BroadleafCommerce/BroadleafCommerce
protected void removeCache(String cacheRegion, Serializable key) {
String cacheName = cacheRegion;
if (key instanceof CacheKey) {
cacheName = ((CacheKey) key).getEntityOrRoleName();
key = ((CacheKey) key).getKey();
}
String nameKey = cacheRegion + '_' + cacheName + '_' + key;
if (cacheMembersByEntity.containsKey(nameKey)) {
String[] members = new String[cacheMembersByEntity.get(nameKey).size()];
members = cacheMembersByEntity.get(nameKey).toArray(members);
for (String myMember : members) {
String itemKey = cacheRegion + '_' + cacheName + '_' + myMember + '_' + key;
getHeap().remove(itemKey);
}
cacheMembersByEntity.remove(nameKey);
}
}
代码示例来源:origin: BroadleafCommerce/BroadleafCommerce
/**
* Remove a specific cache item from the underlying cache
*
* @param cacheName the name of the cache - the ehcache region name
* @param params the appropriate params comprising a unique key for this cache item
*/
protected void removeItemFromCache(String cacheName, String... params) {
String key = buildKey(params);
if (getLogger().isTraceEnabled()) {
getLogger().trace("Evicting [" + key + "] from the [" + cacheName + "] cache.");
}
getCache(cacheName).remove(key);
}
代码示例来源:origin: BroadleafCommerce/BroadleafCommerce
@Override
public void removeFromCache(SystemProperty systemProperty) {
//Could have come from a cache invalidation service that does not
//include the site on the thread, so we should build the key
//including the site (if applicable) from the systemProperty itself
String key = buildKey(systemProperty);
getSystemPropertyCache().remove(key);
// The system property could have been called from the environment,
// so we need to evict that cache key as well
key = buildKey(systemProperty, true);
getSystemPropertyCache().remove(key);
systemPropertiesDao.removeFromCache(systemProperty);
}
代码示例来源:origin: BroadleafCommerce/BroadleafCommerce
@Override
public Boolean removeTranslationPageFromCache(final String uri, String localeCode, boolean isSecure) {
String cacheKey = buildBaseKey(uri, localeCode, isSecure);
List<String> cacheKeys = new ArrayList<>();
cacheKeys.add(cacheKey);
if (queryExtensionManager != null) {
ExtensionResultHolder<List<String>> response = new ExtensionResultHolder<List<String>>();
queryExtensionManager.getProxy().getCacheKeyListForTemplateSite(cacheKey, response);
cacheKeys = response.getResult();
}
for (String cKey : cacheKeys) {
// cacheKeys from the templateSites (extensionManager) are returned with a "templateSiteId:" prefix. Parsing those out to get just the child site keys
if (cKey.contains(":")) {
cKey = cKey.substring(cKey.indexOf(":")+1);
}
getPageCache().remove(cKey);
}
return true;
}
}
代码示例来源:origin: BroadleafCommerce/BroadleafCommerce
@Override
public void removeTranslationFromCache(Translation translation) {
if (BroadleafRequestContext.getBroadleafRequestContext().isProductionSandBox()) {
ResultType resultType = ResultType.STANDARD;
if (extensionManager != null) {
ExtensionResultHolder<ResultType> response = new ExtensionResultHolder<ResultType>();
extensionManager.getProxy().getResultType(translation, response);
resultType = response.getResult();
if (ResultType.STANDARD == resultType) {
String key = getCacheKey(resultType, translation.getEntityType());
LOG.debug("Removing key [" + key + "] for STANDARD site");
getCache().remove(key);
} else {
List<String> cacheKeysList =
getCacheKeyListForTemplateSite(translation.getEntityType().getFriendlyType());
for (String key: cacheKeysList) {
LOG.debug("Removing key [" + key + "] for TEMPLATE site");
getCache().remove(key);
}
}
}
}
}
代码示例来源:origin: pippo-java/pippo
@Override
public void delete(String sessionId) {
this.sessions.remove(sessionId);
}
代码示例来源:origin: Impetus/Kundera
@Override
public void evict(Class arg0, Object arg1)
{
// TODO Can we use Class with ehcache
if(isAlive())
ehcache.remove(arg1);
}
代码示例来源:origin: banq/jdonframework
public void remove(Object key) {
Cache cache = manager.getCache(ehcacheConf.getPredefinedCacheName());
cache.remove(key);
}
代码示例来源:origin: apache/cloudstack
@Override
@DB()
public T findById(final ID id, boolean fresh) {
if (!fresh) {
return findById(id);
}
if (_cache != null) {
_cache.remove(id);
}
return lockRow(id, null);
}
内容来源于网络,如有侵权,请联系作者删除!