@Override public String getCacheKey() { return mdDelegate.getCacheKey(); }
@Override public String getCacheKey() { return qualifiedKey(mdDelegate.getCacheKey()); } };
public void put(QueryMetadata metadata, List results) { String key = metadata.getCacheKey(); if (key == null) { return; } Map<String, List<?>> map = createIfAbsent(metadata); synchronized (map) { map.put(key, results); } }
public List get(QueryMetadata metadata) { String key = metadata.getCacheKey(); if (key == null) { return null; } Map<String, List<?>> map = createIfAbsent(metadata); synchronized (map) { return map.get(key); } }
public String getCacheKey() { return (overrideExists(CACHE_KEY_PROPERTY)) ? (String) overrides .get(CACHE_KEY_PROPERTY) : info.getCacheKey(); }
@Override public List get(QueryMetadata metadata) { String key = Objects.requireNonNull(metadata.getCacheKey()); Cache<String, List> cache = createIfAbsent(metadata); return cache.get(key); }
@Override public void put(QueryMetadata metadata, List results) { String key = Objects.requireNonNull(metadata.getCacheKey()); Cache<String, List> cache = createIfAbsent(metadata); cache.put(key, results); }
@SuppressWarnings("rawtypes") public List get(QueryMetadata metadata) { String key = metadata.getCacheKey(); if (key == null) { return null; } String cacheName = cacheName(metadata); Ehcache cache = cacheManager.getCache(cacheName); if (cache == null) { return null; } Element result = cache.get(key); return result != null ? (List) result.getObjectValue() : null; }
@SuppressWarnings("rawtypes") public void put(QueryMetadata metadata, List results) { String key = metadata.getCacheKey(); if (key != null) { osCache.putInCache(key, results, new String[]{metadata.getCacheGroup()}); } }
@SuppressWarnings("rawtypes") public void put(QueryMetadata metadata, List results) { String key = metadata.getCacheKey(); if (key != null) { String cacheName = cacheName(metadata); Ehcache cache = cacheManager.addCacheIfAbsent(cacheName); cache.put(new Element(key, results)); } }
private boolean interceptIncrementalListConversion() { int pageSize = serverMetadata.getPageSize(); if (pageSize > 0 && serverMetadata.getCacheKey() != null) { List list = response.firstList(); if (list.size() > pageSize && list instanceof IncrementalFaultList) { // cache channel.addPaginatedResult( serverMetadata.getCacheKey(), ((IncrementalFaultList) list)); // extract and convert firts page List sublist = list.subList(0, pageSize); List firstPage = (serverMetadata.isFetchingDataRows()) ? new ArrayList( sublist) : toClientObjects(sublist); this.response = new IncrementalListResponse(firstPage, list.size()); return DONE; } } return !DONE; }
private boolean interceptSinglePageQuery() { // retrieve range from the previously cached list if (serverMetadata.getFetchStartIndex() >= 0 && serverMetadata.getFetchLimit() > 0 && serverMetadata.getCacheKey() != null) { IncrementalFaultList cachedList = channel.getPaginatedResult(serverMetadata .getCacheKey()); if (cachedList == null) { throw new CayenneRuntimeException("No cached list for " + serverMetadata.getCacheKey()); } int startIndex = serverMetadata.getFetchStartIndex(); int endIndex = startIndex + serverMetadata.getFetchLimit(); // send back just one page... query sender will figure out where it fits in // the incremental list this.response = new ListResponse(new ArrayList(cachedList.subList( startIndex, endIndex))); return DONE; } return !DONE; }
@Override public List get(QueryMetadata metadata, QueryCacheEntryFactory factory) { String key = Objects.requireNonNull(metadata.getCacheKey()); Cache<String, List> cache = createIfAbsent(metadata); List<?> result = cache.get(key); return result != null ? result : cache.invoke(key, new JCacheEntryLoader(factory)); }
private boolean interceptIncrementalListConversion() { int pageSize = serverMetadata.getPageSize(); if (pageSize > 0 && serverMetadata.getCacheKey() != null) { List list = response.firstList(); if (list.size() > pageSize && list instanceof IncrementalFaultList) { // cache channel.getQueryCache().put(serverMetadata, list); // extract and convert first page // TODO: andrus, 2008/03/05 - we no longer resolve the first page // automatically on the server... probably should not do it for the client // either... One rare case when this is completely undesirable is // subaction execution from 'interceptSinglePageQuery', as it doesn't even // care about the first page... List sublist = list.subList(0, pageSize); List firstPage = (serverMetadata.isFetchingDataRows()) ? new ArrayList(sublist) : toClientObjects(sublist); this.response = new IncrementalListResponse(firstPage, list.size()); return DONE; } } return !DONE; }
@SuppressWarnings("rawtypes") public List get(QueryMetadata metadata) { String key = metadata.getCacheKey(); if (key == null) { return null; } RefreshSpecification refresh = getRefreshSpecification(metadata); try { return (List) osCache.getFromCache( key, refresh.refreshPeriod, refresh.cronExpression); } catch (NeedsRefreshException e) { osCache.cancelUpdate(key); return null; } }
/** * Returns a non-null cached value. If it is not present in the cache, it is obtained * by calling {@link QueryCacheEntryFactory#createObject()} without blocking the cache. As * a result there is a potential of multiple threads to be updating cache in parallel - * this wouldn't lead to corruption of the cache, but can be suboptimal. */ @SuppressWarnings("rawtypes") public List get(QueryMetadata metadata, QueryCacheEntryFactory factory) { List result = get(metadata); if (result == null) { List newObject = factory.createObject(); if (newObject == null) { throw new CayenneRuntimeException("Null on cache rebuilding: %s", metadata.getCacheKey()); } result = newObject; put(metadata, result); } return result; }
private boolean interceptLocalCache() { String cacheKey = metadata.getCacheKey(); if (cacheKey == null) { return !DONE; } boolean cache = QueryMetadata.LOCAL_CACHE.equals(metadata.getCachePolicy()); boolean cacheOrCacheRefresh = cache || QueryMetadata.LOCAL_CACHE_REFRESH.equals(metadata.getCachePolicy()); if (!cacheOrCacheRefresh) { return !DONE; } ObjectStore objectStore = ((DataContext) actingContext).getObjectStore(); if (cache) { List cachedResults = objectStore.getCachedQueryResult(cacheKey); if (cachedResults != null) { response = new ListResponse(cachedResults); return DONE; } } runQuery(); objectStore.cacheQueryResult(cacheKey, response.firstList()); return DONE; } }
private boolean interceptLocalCache() { String cacheKey = metadata.getCacheKey(); if (cacheKey == null) { return !DONE;
/** * Copies values of this object to another SelectInfo object. */ void copyFromInfo(QueryMetadata info) { this.lastEntityResolver = null; this.lastRoot = null; this.objEntity = null; this.dbEntity = null; this.dataMap = null; this.fetchingDataRows = info.isFetchingDataRows(); this.fetchLimit = info.getFetchLimit(); this.pageSize = info.getPageSize(); this.refreshingObjects = info.isRefreshingObjects(); this.resolvingInherited = info.isResolvingInherited(); this.cachePolicy = info.getCachePolicy(); this.cacheKey = info.getCacheKey(); setPrefetchTree(info.getPrefetchTree()); }
/** * Copies values of another QueryMetadata object to this object. */ void copyFromInfo(QueryMetadata info) { this.lastEntityResolver = null; this.lastRoot = null; this.classDescriptor = null; this.dbEntity = null; this.dataMap = null; this.fetchingDataRows = info.isFetchingDataRows(); this.fetchLimit = info.getFetchLimit(); this.pageSize = info.getPageSize(); this.cacheStrategy = info.getCacheStrategy(); this.cacheKey = info.getCacheKey(); this.cacheGroup = info.getCacheGroup(); this.resultSetMapping = info.getResultSetMapping(); setPrefetchTree(info.getPrefetchTree()); }