Class ExpirationManagerImpl<K,​V>

    • Constructor Detail

      • ExpirationManagerImpl

        public ExpirationManagerImpl()
    • Method Detail

      • start

        public void start()
      • isEnabled

        public boolean isEnabled()
        Specified by:
        isEnabled in interface ExpirationManager<K,​V>
        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>
        entry - the entry that has expired
        currentTime - the current time when it expired
        hasLock - if the expiration was found during a write operation
        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>
        entry - entry that is now expired
        currentTime - the current time in milliseconds
      • handleInStoreExpirationInternal

        public CompletionStage<Void> handleInStoreExpirationInternal​(K key)
        Description copied from interface: InternalExpirationManager
        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:
        handleInStoreExpirationInternal in interface InternalExpirationManager<K,​V>
        key - the key of the expired entry This method will be renamed to handleInStoreExpiration when the method can be removed from ExpirationManager
      • handlePossibleExpiration

        public CompletionStage<Boolean> handlePossibleExpiration​(InternalCacheEntry<K,​V> ice,
                                                                 int segment,
                                                                 boolean isWrite)
        Description copied from interface: InternalExpirationManager
        Handles processing for an entry that may be expired. This will remove the entry if it is expired, otherwise may touch if it uses max idle. The return stage will contain whether the entry was actually expired or not
        Specified by:
        handlePossibleExpiration in interface InternalExpirationManager<K,​V>
        ice - entry that may be expired
        segment - the segment of the entry
        isWrite - whether the command that saw the expired value was a write or not
        a stage that when complete will return if the entry was expired
      • touchEntryAndReturnIfExpired

        protected CompletionStage<Boolean> touchEntryAndReturnIfExpired​(InternalCacheEntry entry,
                                                                        int segment)
        Response is whether the value should be treated as expired - thus if both local and remote were able to touch then the value is not expired. Note this is different then the touch command's response normally as that mentions if it was touched or not
        entry -
        segment -
      • stop

        public void stop()