org.apache.hadoop.hdfs.protocol

## Class CacheDirectiveInfo.Expiration

- java.lang.Object
- - org.apache.hadoop.hdfs.protocol.CacheDirectiveInfo.Expiration

- Enclosing class:
    CacheDirectiveInfo

      public static class CacheDirectiveInfo.Expiration
      extends Object

  Denotes a relative or absolute expiration time for a CacheDirective. Use factory methods `newAbsolute(Date)` and `newRelative(long)` to create an Expiration.

  In either case, the server-side clock is used to determine when a CacheDirective expires.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static long` | `MAX_RELATIVE_EXPIRY_MS` The maximum value we accept for a relative expiry.
    `static CacheDirectiveInfo.Expiration` | `NEVER` An relative Expiration that never expires.

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `Date` | `getAbsoluteDate()`
    `long` | `getAbsoluteMillis()`
    `long` | `getMillis()`
    `boolean` | `isRelative()`
    `static CacheDirectiveInfo.Expiration` | `newAbsolute(Date date)` Create a new absolute Expiration.
    `static CacheDirectiveInfo.Expiration` | `newAbsolute(long ms)` Create a new absolute Expiration.
    `static CacheDirectiveInfo.Expiration` | `newRelative(long ms)` Create a new relative Expiration.
    `String` | `toString()`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### MAX_RELATIVE_EXPIRY_MS

          public static final long MAX_RELATIVE_EXPIRY_MS

      The maximum value we accept for a relative expiry.
      See Also:
        Constant Field Values

    - #### NEVER

          public static final CacheDirectiveInfo.Expiration NEVER

      An relative Expiration that never expires.

  - ### Method Detail

    - #### newRelative

          public static CacheDirectiveInfo.Expiration newRelative(long ms)

      Create a new relative Expiration.

      Use `NEVER` to indicate an Expiration that never expires.

      Parameters:
        `ms` - how long until the CacheDirective expires, in milliseconds
      Returns:
        A relative Expiration

    - #### newAbsolute

          public static CacheDirectiveInfo.Expiration newAbsolute(Date date)

      Create a new absolute Expiration.

      Use `NEVER` to indicate an Expiration that never expires.

      Parameters:
        `date` - when the CacheDirective expires
      Returns:
        An absolute Expiration

    - #### newAbsolute

          public static CacheDirectiveInfo.Expiration newAbsolute(long ms)

      Create a new absolute Expiration.

      Use `NEVER` to indicate an Expiration that never expires.

      Parameters:
        `ms` - when the CacheDirective expires, in milliseconds since the Unix epoch.
      Returns:
        An absolute Expiration

    - #### isRelative

          public boolean isRelative()

      Returns:
        true if Expiration was specified as a relative duration, false if specified as an absolute time.

    - #### getMillis

          public long getMillis()

      Returns:
        The raw underlying millisecond value, either a relative duration or an absolute time as milliseconds since the Unix epoch.

    - #### getAbsoluteDate

          public Date getAbsoluteDate()

      Returns:
        Expiration time as a `Date` object. This converts a relative Expiration into an absolute Date based on the local clock.

    - #### getAbsoluteMillis

          public long getAbsoluteMillis()

      Returns:
        Expiration time in milliseconds from the Unix epoch. This converts a relative Expiration into an absolute time based on the local clock.

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

Copyright © 2008–2022 Apache Software Foundation. All rights reserved.