public void delete(String key) { ehCache.remove(key); }
/** * 删除缓存记录 * @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); }
public void removeCache(String group, String key) { if (cacheManager.getCache(group) != null) { cacheManager.getCache(group).remove(key); } }
public static void remove(String cacheName, Object key) { getOrAddCache(cacheName).remove(key); }
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; } } } } } }
@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; }
@Override public void remove(String region, String key) { Cache cacheRegion = getRegion(region); cacheRegion.remove(key); }
public static void clearCache() { long threadId = Thread.currentThread().getId(); getCache().remove(threadId); }
public static void remove(String cacheName, Object key) { getOrAddCache(cacheName).remove(key); }
@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; }
@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; }
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); } }
/** * 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); }
@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); }
@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; } }
@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); } } } } }
@Override public void delete(String sessionId) { this.sessions.remove(sessionId); }
@Override public void evict(Class arg0, Object arg1) { // TODO Can we use Class with ehcache if(isAlive()) ehcache.remove(arg1); }
public void remove(Object key) { Cache cache = manager.getCache(ehcacheConf.getPredefinedCacheName()); cache.remove(key); }
@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); }