Class ExpirationManagerImpl<K,​V>

    • Field Detail

      • timeService

        protected org.infinispan.commons.time.TimeService timeService
      • enabled

        protected boolean enabled
      • cacheName

        protected String cacheName
      • expiring

        protected ConcurrentMap<K,​Object> expiring
        This map is used for performance reasons. Essentially when an expiration event should not be raised this map should be populated first. The main examples are if an expiration is about to occur for that key or the key will be removed or updated. In the latter case we don't want to send an expiration event and then a remove event when we could do just the removal.
    • Constructor Detail

      • ExpirationManagerImpl

        public ExpirationManagerImpl()
    • Method Detail

      • start

        public void start()
      • isEnabled

        public boolean isEnabled()
        Specified by:
        isEnabled in interface ExpirationManager<K,​V>
        Returns:
        true if expiration reaper thread is enabled, false otherwise
      • entryExpiredInMemory

        public CompletableFuture<Boolean> entryExpiredInMemory​(InternalCacheEntry<K,​V> entry,
                                                               long currentTime,
                                                               boolean hasLock)
        Description copied from interface: InternalExpirationManager
        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.

        Specified by:
        entryExpiredInMemory in interface InternalExpirationManager<K,​V>
        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
      • handleInMemoryExpiration

        public void handleInMemoryExpiration​(InternalCacheEntry<K,​V> entry,
                                             long currentTime)
        Description copied from interface: ExpirationManager
        This should be invoked passing in an entry that is now expired. This method may attempt to lock this key to preserve atomicity.
        Specified by:
        handleInMemoryExpiration in interface ExpirationManager<K,​V>
        Parameters:
        entry - entry that is now expired
        currentTime - the current time in milliseconds
      • localLastAccess

        protected Long localLastAccess​(Object key,
                                       Object value,
                                       int segment)
      • retrieveLastAccess

        public CompletableFuture<Long> retrieveLastAccess​(Object key,
                                                          Object value,
                                                          int segment)
        Description copied from interface: InternalExpirationManager
        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>
        Specified by:
        retrieveLastAccess in interface InternalExpirationManager<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
      • stop

        public void stop()