Refine search
public Object get(String key) { Element e = ehCache.get(key); return (e == null) ? null : e.getObjectValue(); }
/** * 获取缓存记录 * @param cacheName * @param key * @return */ public static Object get(String cacheName, String key) { Cache cache = getCache(cacheName); if (null == cache) { return null; } Element cacheElement = cache.get(key); if (null == cacheElement) { return null; } return cacheElement.getObjectValue(); }
@SuppressWarnings("unchecked") public static <T> T get(String cacheName, Object key) { Element element = getOrAddCache(cacheName).get(key); return element != null ? (T)element.getObjectValue() : null; }
@Override public Object getHydratedCacheElementItem(String cacheRegion, String cacheName, Serializable elementKey, String elementItemName) { Object response = null; Element element; String myKey = cacheRegion + '_' + cacheName + '_' + elementItemName + '_' + elementKey; element = getHeap().get(myKey); if (element != null) { response = element.getObjectValue(); } return response; }
@SuppressWarnings("all") public static <T> T get(String cacheName, Object key) { Element element = getOrAddCache(cacheName).get(key); if (element == null) { return null; } else { Object objectValue = element.getObjectValue(); return (T) objectValue; } }
protected Date getCachedDate(final String key) { final Element element = getUriCachedDateCache().get(key); final Date cachedDate; if (element != null && element.getObjectValue() != null) { cachedDate = (Date) element.getObjectValue(); } else { cachedDate = new Date(); } return cachedDate; }
public <T> T getCache(String group, String key) { try { createIfMissing(group); Cache c = cacheManager.getCache(group); return (T) (c.get(key) == null ? null : c.get(key).getObjectValue()); } catch (Exception e) { logger.warn("%s", e, e); return null; } }
protected static Map<String, Translation> getThreadlocalCache() { long threadId = Thread.currentThread().getId(); Element cacheElement = getCache().get(threadId); return cacheElement == null ? null : (Map<String, Translation>) cacheElement.getObjectValue(); }
protected URLHandler getUrlHandlerFromCache(String key) { Element cacheElement = getUrlHandlerCache().get(key); if (cacheElement != null) { return (URLHandler) cacheElement.getObjectValue(); } return null; }
@Override public Object get(String region, String key) { Cache cacheRegion = getRegion(region); Element element = cacheRegion.get(key); if (element != null) { return element.getObjectValue(); } else { return null; } }
@Override public Object getHydratedCacheElementItem(String cacheRegion, String cacheName, Serializable elementKey, String elementItemName) { Element element; String myKey = cacheRegion + '_' + cacheName + '_' + elementItemName + '_' + elementKey; if (removeKeys.contains(myKey)) { return null; } Object response = null; element = getHeap().get(myKey); if (element != null) { response = element.getObjectValue(); } return response; }
protected boolean isNullPageCached(Locale locale, String uri, boolean secure) { boolean result = false; final String cacheKey = buildKey(uri, locale, secure); if (getPageCache().get(cacheKey) != null) { Object pageDto = ((List) this.getPageCache().get(cacheKey).getObjectValue()).get(0); if (pageDto instanceof NullPageDTO) { result = true; } } return result; }
protected String getPropertyFromCache(String propertyName) { String key = buildKey(propertyName); Element cacheElement = getSystemPropertyCache().get(key); if (cacheElement != null && cacheElement.getObjectValue() != null) { return (String) cacheElement.getObjectValue(); } return null; }
public synchronized long incr(String key, int by) { Element e = ehCache.get(key); if (e == null) { return -1; } long newValue = ((Number) e.getObjectValue()).longValue() + by; Element newE = new Element(key, newValue); newE.setTimeToLive(e.getTimeToLive()); ehCache.put(newE); return newValue; }
public synchronized long decr(String key, int by) { Element e = ehCache.get(key); if (e == null) { return -1; } long newValue = ((Number) e.getObjectValue()).longValue() - by; Element newE = new Element(key, newValue); newE.setTimeToLive(e.getTimeToLive()); ehCache.put(newE); return newValue; }
@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 public boolean isUserQualifiedForOperationOnCeilingEntity(AdminUser adminUser, PermissionType permissionType, String ceilingEntityFullyQualifiedName) { Boolean response = null; String cacheKey = buildCacheKey(adminUser, permissionType, ceilingEntityFullyQualifiedName); Element cacheElement = cache.get(cacheKey); if (cacheElement != null) { response = (Boolean) cacheElement.getObjectValue(); if (LOG.isTraceEnabled()) { LOG.trace("Admin Security Cache GET For: \"" + cacheKey + "\" = " + response); } } if (response == null) { response = adminPermissionDao.isUserQualifiedForOperationOnCeilingEntity(adminUser, permissionType, ceilingEntityFullyQualifiedName); if (!response) { response = adminPermissionDao.isUserQualifiedForOperationOnCeilingEntityViaDefaultPermissions(ceilingEntityFullyQualifiedName); } cacheElement = new Element(cacheKey, response); cache.put(cacheElement); if (LOG.isTraceEnabled()) { LOG.trace("Admin Security Cache PUT For: \"" + cacheKey + "\" = " + response); } } return response; }
@SuppressWarnings("unchecked") protected void addPageMapCacheEntry(String identifier, String key) { BroadleafRequestContext context = BroadleafRequestContext.getBroadleafRequestContext(); Site site = context.getNonPersistentSite(); Long siteId = (site != null) ? site.getId() : null; String mapKey = getPageMapCacheKey(identifier, siteId); if (mapKey != null) { Element e = getPageMapCache().get(mapKey); if (e == null || e.getObjectValue() == null) { List<String> keys = new ArrayList<>(); keys.add(key); getPageMapCache().put(new Element(mapKey, keys)); } else { ((List<String>) e.getObjectValue()).add(mapKey); } } }
@SuppressWarnings("unchecked") protected List<PageDTO> getPageListFromCache(String key) { if (key != null) { Element cacheElement = getPageCache().get(key); if (cacheElement != null && cacheElement.getObjectValue() != null) { statisticsService.addCacheStat(CacheStatType.PAGE_CACHE_HIT_RATE.toString(), true); return (List<PageDTO>) cacheElement.getObjectValue(); } statisticsService.addCacheStat(CacheStatType.PAGE_CACHE_HIT_RATE.toString(), false); } return null; }
@Override public List<StructuredContentDTO> getStructuredContentListFromCache(String key) { Element scElement = getStructuredContentCache().get(key); if (scElement != null) { statisticsService.addCacheStat(CacheStatType.STRUCTURED_CONTENT_CACHE_HIT_RATE.toString(), true); return (List<StructuredContentDTO>) scElement.getObjectValue(); } statisticsService.addCacheStat(CacheStatType.STRUCTURED_CONTENT_CACHE_HIT_RATE.toString(), false); return null; }