Class VersionedCacheEntry<T>

  • Type Parameters:
    T - The type stored in this cache entry
    All Implemented Interfaces:
    Serializable, Supplier<Optional<T>>

    public class VersionedCacheEntry<T>
    extends CacheEntry<T>
    A plugin version aware extension of CacheEntry, which will consider itself expired whenever the plugin version has changed from the version at entry creation.

    Instances of this class are NOT Serializable, because it doesn’t make sense to serialize a plugin-versioned object.

    See Also:
    Serialized Form
    • Constructor Detail

      • VersionedCacheEntry

        public VersionedCacheEntry​(CacheEntry<? extends T> entry)
        Copy constructor for another cache entry.

        If the other entry is a VersionedCacheEntry, its pluginVersion will also be copied. Otherwise, the current plugin version will be used.

        This should be used with caution, because you can construct a versioned object that looks right, but is not.

        Parameters:
        entry - The entry to copy
      • VersionedCacheEntry

        public VersionedCacheEntry​(T entryValue,
                                   long futureTimeAmount,
                                   TimeUnit timeUnit)
        Constructs a new VersionedCacheEntry expiring at the given time in the future
        Parameters:
        entryValue - The value being cached
        futureTimeAmount - The number of time units in the future to expire this entry
        timeUnit - The time unit (e.g., seconds) to calculate the expiration time
      • VersionedCacheEntry

        public VersionedCacheEntry​(T entryValue,
                                   Date entryExpiration)
        Constructs a new VersionedCacheEntry expiring at the given Date
        Parameters:
        entryValue - The value being cached
        entryExpiration - The
      • VersionedCacheEntry

        public VersionedCacheEntry​(T entryValue,
                                   long entryExpirationTimestampMillis)
        Constructs a new VersionedCacheEntry expiring at the given epoch millisecond timestamp
        Parameters:
        entryValue - The value being cached
        entryExpirationTimestampMillis - The epoch millisecond timestamp after which this entry is expired