Class GroupedKey

java.lang.Object
me.ahoo.cosid.segment.grouped.GroupedKey

public final class GroupedKey extends Object
Key used for grouping/sharding of ID segments.

Represents a logical grouping key with an optional TTL for time-based sharding strategies (e.g., daily or monthly buckets).

  • Field Details

    • NEVER

      public static final GroupedKey NEVER
      Sentinel value indicating no grouping.
  • Constructor Details

    • GroupedKey

      public GroupedKey(String key, long ttlAt)
      Creates a new GroupedKey.
      Parameters:
      key - the grouping key (e.g., "2024-01" for monthly)
      ttlAt - the time-to-live expiration timestamp in seconds
  • Method Details

    • getKey

      public String getKey()
      Gets the grouping key.
      Returns:
      the key
    • getTtlAt

      public long getTtlAt()
      Gets the TTL expiration timestamp.
      Returns:
      TTL timestamp in seconds
      See Also:
    • ttl

      public long ttl()
      Calculates remaining TTL from current time.
      Returns:
      remaining TTL in seconds, or 0 if expired
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • forever

      public static GroupedKey forever(String key)
      Creates a GroupedKey that never expires.
      Parameters:
      key - the grouping key
      Returns:
      a forever GroupedKey