/** * * @param oid * @param pc * @return */ @Override protected DataCachePCData putInternal(Object oid, DataCachePCData pc) { Ehcache cache = findCache(pc.getType()); if (cache != null) { cache.put(new Element(oid, pc)); } return pc; }
public DataCachePCData put(DataCachePCData data) { DataCachePCData o = putInternal(data.getId(), data); if (log.isTraceEnabled()) log.trace(s_loc.get("cache-put", data.getId())); return (o == null || o.isTimedOut()) ? null : o; }
/** * Transforms a collection of {@link PCDataHolder}s that might contain * stale instances into a collection of up-to-date {@link DataCachePCData}s. */ private List<DataCachePCData> transformToVersionSafePCDatas(DataCache cache, List<PCDataHolder> holders) { List<DataCachePCData> transformed = new ArrayList<DataCachePCData>(holders.size()); Map<Object,Integer> ids = new HashMap<Object,Integer>(holders.size()); // this list could be removed if DataCache.getAll() took a Collection List<Object> idList = new ArrayList<Object>(holders.size()); int i = 0; for (PCDataHolder holder : holders) { ids.put(holder.sm.getObjectId(), i++); idList.add(holder.sm.getObjectId()); } Map<Object,DataCachePCData> pcdatas = cache.getAll(idList); for (Entry<Object,DataCachePCData> entry : pcdatas.entrySet()) { Integer index = ids.get(entry.getKey()); DataCachePCData oldpc = entry.getValue(); PCDataHolder holder = holders.get(index); if (oldpc != null && compareVersion(holder.sm, holder.sm.getVersion(), oldpc.getVersion()) == VERSION_EARLIER) continue; else transformed.add(holder.pcdata); } return transformed; }
sm.initialize(data.getType(), state); data.load(sm, fetch, edata); } else unloaded = addUnloaded(sm, null, unloaded); data.load(sm, fields, fetch, edata); if (fields.length() > 0) unloaded = addUnloaded(sm, fields, unloaded); data = cache.get(sm.getObjectId()); if (data != null && compareVersion(sm, sm.getVersion(), data.getVersion()) == VERSION_EARLIER) continue; data = newPCData(sm); if (fields == null) data.store(sm); else data.store(sm, fields); if (isNew) cache.put(data);
DataCachePCData data = cache.get(sm.getObjectId()); if (lockLevel == LockLevels.LOCK_NONE && !isLocking(fetch) && data != null) data.load(sm, fields, fetch, edata); if (fields.length() == 0){ if (stats.isEnabled()) { Class<?> cls = (data == null) ? sm.getMetaData().getDescribedType() : data.getType(); ((CacheStatisticsSPI)stats).newGet(cls, true);
public boolean contains(Object key) { DataCachePCData o = getInternal(key); if (o != null && o.isTimedOut()) { o = null; removeInternal(key); if (log.isTraceEnabled()) log.trace(s_loc.get("cache-timeout", key)); } return o != null; }
/** * Add all of the given objects to the cache. */ protected void putAllInternal(Collection<DataCachePCData> pcs) { for (DataCachePCData pc : pcs) { putInternal(pc.getId(), pc); } }
data = cache.get(sm.getObjectId()); if (!isLocking(null) && data != null) version = data.getVersion(); ((CacheStatisticsSPI)stats).newGet(data.getType(), true); Class<?> cls = (data == null) ? sm.getMetaData().getDescribedType() : data.getType(); ((CacheStatisticsSPI) stats).newGet(cls, false);
data.store(sm); mods.additions.add(new PCDataHolder(data, sm)); CacheStatistics stats = cache.getStatistics(); if (stats.isEnabled()) { ((CacheStatisticsSPI)stats).newPut(data.getType()); data.store(sm); mods.newUpdates.add(new PCDataHolder(data, sm)); } else { data.store(sm, fields); mods.existingUpdates.add(new PCDataHolder(data, sm)); ((CacheStatisticsSPI)stats).newPut(data.getType());
private void cacheStateManager(DataCache cache, OpenJPAStateManager sm, DataCachePCData data) { if (sm.isFlushed()) { return; } // make sure that we're not trying to cache an old version cache.writeLock(); try { if (data != null && compareVersion(sm, sm.getVersion(), data.getVersion()) == VERSION_EARLIER) { return; } // cache newly loaded info. It is safe to cache data frorm // initialize() because this method is only called upon // initial load of the data. boolean isNew = data == null; if (isNew) { data = newPCData(sm, cache); } data.store(sm); if (isNew) { cache.put(data); } else { cache.update(data); } } finally { cache.writeUnlock(); } }
if (lockLevel == LockLevels.LOCK_NONE && !isLocking(fetch) && data != null) data.load(sm, fields, fetch, edata); if (fields.length() == 0) return true; data = cache.get(sm.getObjectId()); if (data != null && compareVersion(sm, sm.getVersion(), data.getVersion()) == VERSION_EARLIER) return true; if (isNew) data = newPCData(sm); data.store(sm, fields); if (isNew) cache.put(data);
((CacheStatisticsSPI) stats).newGet(data.getType(), true); sm.initialize(data.getType(), state); data.load(sm, fetch, edata); } else { unloaded = addUnloaded(sm, null, unloaded); data.load(sm, fields, fetch, edata); if (fields.length() > 0){ unloaded = addUnloaded(sm, fields, unloaded); if (stats.isEnabled()) { ((CacheStatisticsSPI)stats).newGet(data.getType(), false); ((CacheStatisticsSPI)stats).newGet(data.getType(), true); data = cache.get(sm.getObjectId()); if (data != null && compareVersion(sm, sm.getVersion(), data.getVersion()) == VERSION_EARLIER) continue; data = newPCData(sm, cache); if (fields == null) data.store(sm); else data.store(sm, fields); if (isNew) cache.put(data); CacheStatistics stats = cache.getStatistics();
DataCachePCData data = cache.get(sm.getObjectId()); if (lockLevel == LockLevels.LOCK_NONE && !isLocking(fetch) && data != null) data.load(sm, fields, fetch, edata); if (fields.length() == 0){ if (stats.isEnabled()) { Class<?> cls = (data == null) ? sm.getMetaData().getDescribedType() : data.getType(); ((CacheStatisticsSPI)stats).newGet(cls, true);
public boolean contains(Object key) { DataCachePCData o = getInternal(key); if (o != null && o.isTimedOut()) { o = null; removeInternal(key); if (log.isTraceEnabled()) log.trace(s_loc.get("cache-timeout", key)); } return o != null; }
/** * Add all of the given objects to the cache. */ protected void putAllInternal(Collection<DataCachePCData> pcs) { for (DataCachePCData pc : pcs) { putInternal(pc.getId(), pc); } }
data = cache.get(sm.getObjectId()); if (!isLocking(null) && data != null) version = data.getVersion(); ((CacheStatisticsSPI)stats).newGet(data.getType(), true); Class<?> cls = (data == null) ? sm.getMetaData().getDescribedType() : data.getType(); ((CacheStatisticsSPI) stats).newGet(cls, false);
data.store(sm); mods.additions.add(new PCDataHolder(data, sm)); CacheStatistics stats = cache.getStatistics(); if (stats.isEnabled()) { ((CacheStatisticsSPI)stats).newPut(data.getType()); data.store(sm); mods.newUpdates.add(new PCDataHolder(data, sm)); } else { data.store(sm, fields); mods.existingUpdates.add(new PCDataHolder(data, sm)); ((CacheStatisticsSPI)stats).newPut(data.getType());
private void cacheStateManager(DataCache cache, OpenJPAStateManager sm, DataCachePCData data) { if (sm.isFlushed()) { return; } // make sure that we're not trying to cache an old version cache.writeLock(); try { if (data != null && compareVersion(sm, sm.getVersion(), data.getVersion()) == VERSION_EARLIER) { return; } // cache newly loaded info. It is safe to cache data frorm // initialize() because this method is only called upon // initial load of the data. boolean isNew = data == null; if (isNew) { data = newPCData(sm, cache); } data.store(sm); if (isNew) { cache.put(data); } else { cache.update(data); } } finally { cache.writeUnlock(); } }
sm.initialize(data.getType(), state); data.load(sm, fetch, edata); return true; data = cache.get(sm.getObjectId()); if (data != null && compareVersion(sm, sm.getVersion(), data.getVersion()) == VERSION_EARLIER) return true; data.store(sm); cache.put(data); } finally {