Examples of Level2Cache


Examples of org.datanucleus.cache.Level2Cache

        }

        // Try Level 2 since not in Level 1
        if (omf.hasLevel2Cache())
        {
            Level2Cache l2Cache = omf.getLevel2Cache();
            synchronized (l2Cache)
            {
                CachedPC cachedPC = l2Cache.get(id);

                // Create active version of cached object with StateManager connected and same id
                if (cachedPC != null)
                {
                    sm = StateManagerFactory.newStateManagerForCachedPC(this, id, cachedPC);
                    pc = sm.getObject(); // Object in P_CLEAN state
                    if (NucleusLogger.CACHE.isDebugEnabled())
                    {
                        NucleusLogger.CACHE.debug(LOCALISER.msg("004006",
                            StringUtils.toJVMIDString(pc), getIdentityAsString(id),
                            StringUtils.booleanArrayToString(cachedPC.getLoadedFields()),
                            StringUtils.objectArrayToString(cachedPC.getRelationFieldNames()),
                            "" + l2Cache.getSize()));
                    }
                    if (tx.isActive() && tx.getOptimistic())
                    {
                        // Optimistic txns, so return as P_NONTRANS (as per JDO2 spec)
                        sm.makeNontransactional();
                    }
                    else if (!tx.isActive() && getApiAdapter().isTransactional(pc))
                    {
                        // Non-tx context, so return as P_NONTRANS (as per JDO2 spec)
                        sm.makeNontransactional();
                    }

                    return pc;
                }
                else
                {
                    if (NucleusLogger.CACHE.isDebugEnabled())
                    {
                        NucleusLogger.CACHE.debug(LOCALISER.msg("004005",
                            getIdentityAsString(id), "" + l2Cache.getSize()));
                    }
                }
            }
        }
View Full Code Here

Examples of org.jpox.cache.Level2Cache

        }

        // Evict from the L2 cache
        if (level2 && omf.getBooleanProperty("org.jpox.cache.level2") && getApiAdapter().getIdForObject(pc) != null)
        {
            Level2Cache l2Cache = omf.getLevel2Cache();
            if (JPOXLogger.CACHE.isDebugEnabled())
            {
                JPOXLogger.CACHE.debug(LOCALISER.msg("004007",
                    StringUtils.toJVMIDString(pc), getApiAdapter().getIdForObject(pc), String.valueOf(l2Cache.getSize())));
            }
            l2Cache.evict(getApiAdapter().getIdForObject(pc));
        }
    }
View Full Code Here

Examples of org.jpox.cache.Level2Cache

        }

        // Try Level 2 since not in Level 1
        if (omf.getBooleanProperty("org.jpox.cache.level2"))
        {
            Level2Cache l2Cache = omf.getLevel2Cache();
            CachedPC cachedPC = l2Cache.get(id);

            // Copy the cached object and connect to a StateManager, with the same object id
            if (cachedPC != null)
            {
                sm = StateManagerFactory.newStateManagerForCachedPC(this,
                    cachedPC.getPersistableObject(), id, cachedPC.getLoadedFields());
                if (cachedPC.getVersion() != null)
                {
                    sm.setVersion(cachedPC.getVersion());
                }
                pc = sm.getObject();
                if (JPOXLogger.CACHE.isDebugEnabled())
                {
                    JPOXLogger.CACHE.debug(LOCALISER.msg("004006",
                        StringUtils.toJVMIDString(pc), id, "" + l2Cache.getSize()));
                }
                cache.put(id, sm); // Put into L1 cache for easy referencing
                return pc;
            }
            else
            {
                if (JPOXLogger.CACHE.isDebugEnabled())
                {
                    JPOXLogger.CACHE.debug(LOCALISER.msg("004005",
                        id, "" + l2Cache.getSize()));
                }
            }
        }

        return null;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.