Class CacheManager.CacheTransactionHandle

  • Enclosing class:
    CacheManager

    protected class CacheManager.CacheTransactionHandle
    extends java.lang.Object
    This is the class the cache manager uses to keep track of transaction relationships and data. Since a transaction is local to a thread, this class is local to a specific thread as well; it is thus referenced by a thread-local hash table.
    • Field Detail

      • objectHash

        protected java.util.HashMap objectHash
        This is the object hash (key is the description object, value is the stored object).
      • cacheKeyMap

        protected java.util.HashMap cacheKeyMap
        This is the cache key map (key is the cache key, value is a hashmap containing the object descriptions to be invalidated).
      • cacheKeyReadLocks

        protected java.util.HashMap cacheKeyReadLocks
        This is the set of cache key read locks that are currently held by this transaction.
      • cacheKeyWriteLocks

        protected java.util.HashMap cacheKeyWriteLocks
        This is the set of cache key write locks that are currently held by this transaction.
      • invalidationKeys

        protected StringSetBuffer invalidationKeys
        This is the current set of keys to invalidate if the transaction should be committed.
    • Constructor Detail

      • CacheTransactionHandle

        public CacheTransactionHandle​(CacheManager.CacheTransactionHandle parentTransaction)
        Constructor.
        Parameters:
        parentTransaction - is the parent transaction identifier, or null if none.
    • Method Detail

      • getWriteLocks

        public StringSet getWriteLocks()
        Get the set of write locks to close on exit from this transaction.
        Returns:
        the write lock names as an array.
      • getReadLocks

        public StringSet getReadLocks()
        Get the set of read locks to close on exit from this transaction.
        Returns:
        the read lock names as an array.
      • getInvalidationKeys

        public StringSet getInvalidationKeys()
        Get the current invalidation keys.
        Returns:
        the keys as a stringset
      • lookupObject

        public java.lang.Object lookupObject​(ICacheDescription descriptionObject)
        Look for an object in cache.
        Parameters:
        descriptionObject - is the cache description object.
        Returns:
        the object, if found, or null if not found.
      • saveObject

        public void saveObject​(ICacheDescription descriptionObject,
                               java.lang.Object object,
                               StringSet cacheKeys)
        Save an object in cache.
        Parameters:
        descriptionObject - is the description.
        object - is the object to save.
        cacheKeys - are the cache keys.
      • invalidateKeys

        public void invalidateKeys​(StringSet keys)
        Invalidate objects.
        Parameters:
        keys - is the set of keys to invalidate.
      • checkCacheKeys

        public boolean checkCacheKeys​(StringSet cacheKeys)
        See if cache keys intersect with invalidation keys.
        Parameters:
        cacheKeys - is the set of cache keys that describe an object.
        Returns:
        true if these keys have been invalidated in this transaction
      • getRemainingReadLocks

        public StringSet getRemainingReadLocks​(StringSet cacheKeys,
                                               StringSet keys)
        Come up with the set of read locks we still need to throw.
        Parameters:
        cacheKeys - is the set of cache keys we need to have read locks for.
        keys - is the set of invalidation keys we need to have write locks for.
        Returns:
        the array of read locks we still need to throw.
      • getRemainingWriteLocks

        public StringSet getRemainingWriteLocks​(StringSet cacheKeys,
                                                StringSet keys)
                                         throws ManifoldCFException
        Come up with the set of write locks we still need to throw.
        Parameters:
        cacheKeys - is the set of cache keys we need to have read locks for.
        keys - is the set of invalidation keys we need to have write locks for.
        Returns:
        the array of write locks we still need to throw.
        Throws:
        ManifoldCFException
      • addLocks

        public void addLocks​(StringSet thrownReadLocks,
                             StringSet thrownWriteLocks)
        Add to the set of locks that are open.
        Parameters:
        thrownReadLocks - is the set of read locks.
        thrownWriteLocks - is the set of write locks.
      • getCurrentObjects

        public java.util.Iterator getCurrentObjects()
        Get all existing object descriptions.
        Returns:
        an iterator of ICacheDescription objects.