Interface InternalExpirationManager<K,​V>

    • Method Detail

      • entryExpiredInMemory

        CompletableFuture<Boolean> entryExpiredInMemory​(InternalCacheEntry<K,​V> entry,
                                                        long currentTime,
                                                        boolean hasLock)
        This should be invoked passing in an entry that is now expired. This method may attempt to lock this key to preserve atomicity. This method should be invoked when an entry was read via get but found to be expired.

        This method returns true if the entry was removed due to expiration or false if the entry was not removed due to expiration

        If hasLock is true, this method assumes that the caller has the lock for the key and it must allow the expiration to occur, ie. returned CompletableFuture has completed, before the lock is released. Failure to do so may cause inconsistency in data.

        Parameters:
        entry - the entry that has expired
        currentTime - the current time when it expired
        hasLock - if the expiration was found during a write operation
        Returns:
        if this entry actually expired or not
      • entryExpiredInMemoryFromIteration

        CompletableFuture<Boolean> entryExpiredInMemoryFromIteration​(InternalCacheEntry<K,​V> entry,
                                                                     long currentTime)
        This method is very similar to entryExpiredInMemory(InternalCacheEntry, long, boolean) except that it does the bare minimum when an entry expired to guarantee if the entry is valid or not. This is important to reduce time spent per entry when iterating. This method may not actually remove the entry and may just return immediately if it is safe to do so.
        Parameters:
        entry - the entry that has expired
        currentTime - the current time when it expired
        Returns:
        if this entry actually expired or not
      • handleInStoreExpiration

        void handleInStoreExpiration​(K key)
        This is to be invoked when a store entry expires. This method may attempt to lock this key to preserve atomicity.

        Note this method doesn't currently take a InternalCacheEntry and this is due to a limitation in the cache store API. This may cause some values to be removed if they were updated at the same time.

        Specified by:
        handleInStoreExpiration in interface ExpirationManager<K,​V>
        Parameters:
        key - the key of the expired entry
      • retrieveLastAccess

        CompletableFuture<Long> retrieveLastAccess​(Object key,
                                                   Object value,
                                                   int segment)
        Retrieves the last access time for the given key in the data container if it is using max idle. If the entry is not in the container or it is expired it will return null. If the entry is present but cannot expire via max idle, it will return -1 If the entry is present and can expire via max idle but hasn't it will return a number > 0
        Specified by:
        retrieveLastAccess in interface ExpirationManager<K,​V>
        Parameters:
        key - the key to retrieve the access time for
        value - the value to match if desired (this can be null)
        segment - the segment for the given key
        Returns:
        the last access time if available