Class XATransactionStore

    • Constructor Detail

      • XATransactionStore

        public XATransactionStore​(TransactionManagerLookup transactionManagerLookup,
                                  SoftLockManager softLockManager,
                                  TransactionIDFactory transactionIdFactory,
                                  Ehcache cache,
                                  Store store,
                                  ElementValueComparator comparator)
        Constructor
        Parameters:
        transactionManagerLookup - the transaction manager lookup implementation
        softLockManager - the soft lock manager
        transactionIdFactory - the transaction ID factory
        cache - the cache
        store - the underlying store
    • Method Detail

      • getOrCreateXAResource

        public EhcacheXAResourceImpl getOrCreateXAResource()
                                                    throws javax.transaction.SystemException
        Get or create the XAResource of this XA store
        Returns:
        the EhcacheXAResource of this store
        Throws:
        javax.transaction.SystemException - when something goes wrong with the transaction manager
      • get

        public Element get​(java.lang.Object key)
        Gets an item from the cache.
      • getQuiet

        public Element getQuiet​(java.lang.Object key)
        Gets an Element from the Store, without updating statistics
        Returns:
        The element
      • getSize

        public int getSize()
        Returns the current local store size
        Returns:
        the count of the Elements in the Store on the local machine
      • getTerracottaClusteredSize

        public int getTerracottaClusteredSize()
        Returns the current Terracotta clustered store size
        Returns:
        the count of the Elements in the Store across the cluster
      • containsKey

        public boolean containsKey​(java.lang.Object key)
        A check to see if a key is in the Store.
        Parameters:
        key - The Element key
        Returns:
        true if found. No check is made to see if the Element is expired. 1.2
      • getKeys

        public java.util.List getKeys()
        Gets an Array of the keys for all elements in the disk store.
        Returns:
        An List of Serializable keys
      • put

        public boolean put​(Element element)
                    throws CacheException
        Puts an item into the store.
        Returns:
        true if this is a new put for the key or element is null. Returns false if it was an update.
        Throws:
        CacheException
      • putWithWriter

        public boolean putWithWriter​(Element element,
                                     CacheWriterManager writerManager)
                              throws CacheException
        Puts an item into the store and the cache writer manager in an atomic operation
        Returns:
        true if this is a new put for the key or element is null. Returns false if it was an update.
        Throws:
        CacheException
      • remove

        public Element remove​(java.lang.Object key)
        Removes an item from the cache.
      • removeAll

        public void removeAll()
                       throws CacheException
        Remove all of the elements from the store.

        If there are registered CacheEventListeners they are notified of the expiry or removal of the Element as each is removed.

        Throws:
        CacheException
      • putIfAbsent

        public Element putIfAbsent​(Element element)
                            throws java.lang.NullPointerException
        Put an element in the store if no element is currently mapped to the elements key.
        Parameters:
        element - element to be added
        Returns:
        the element previously cached for this key, or null if none.
        Throws:
        java.lang.NullPointerException - if the element is null, or has a null key
      • removeElement

        public Element removeElement​(Element element,
                                     ElementValueComparator comparator)
                              throws java.lang.NullPointerException
        Remove the Element mapped to the key for the supplied element if the value of the supplied Element is equal to the value of the cached Element. This is a CAS operation. It is consistent even against a distributed cache that is not coherent. If the old value is stale when this operation is attempted the remove does not take place.
        Parameters:
        element - Element to be removed
        comparator - ElementValueComparator to use to compare elements
        Returns:
        the Element removed or null if no Element was removed
        Throws:
        java.lang.NullPointerException - if the element is null, or has a null key
      • replace

        public boolean replace​(Element old,
                               Element element,
                               ElementValueComparator comparator)
                        throws java.lang.NullPointerException,
                               java.lang.IllegalArgumentException
        Replace the cached element only if the value of the current Element is equal to the value of the supplied old Element.
        Parameters:
        old - Element to be test against
        element - Element to be cached
        comparator - ElementValueComparator to use to compare elements
        Returns:
        true is the Element was replaced
        Throws:
        java.lang.NullPointerException - if the either Element is null or has a null key
        java.lang.IllegalArgumentException - if the two Element keys are non-null but not equal
      • replace

        public Element replace​(Element element)
                        throws java.lang.NullPointerException
        Replace the cached element only if an Element is currently cached for this key
        Parameters:
        element - Element to be cached
        Returns:
        the Element previously cached for this key, or null if no Element was cached
        Throws:
        java.lang.NullPointerException - if the Element is null or has a null key