@supuwoerc/toolkit
    Preparing search index...

    Class ValueWithTTL<T>

    带有生存时间(TTL)的值包装类 A value wrapper class with Time-To-Live (TTL) support

    Type Parameters

    • T

      存储值的类型 / Type of the stored value

    Index

    Constructors

    Properties

    Methods

    Constructors

    • 创建带有TTL的值实例 Creates a value instance with TTL

      Type Parameters

      • T

        存储值的类型 / Type of the stored value

      Parameters

      • value: T

        要存储的值 / The value to store

      • ttl: number

        生存时间(毫秒) / Time-to-live in milliseconds

      Returns ValueWithTTL<T>

      当ttl不是整数或小于等于0时抛出 / Throws when ttl is not integer or <= 0

    Properties

    expiry: number

    过期时间戳(毫秒) / Expiration timestamp in milliseconds

    value: T

    存储的实际值 / The actual stored value

    Methods

    • 检查值是否已过期 Checks if the value has expired

      Returns boolean

      true表示已过期,false表示未过期 / true if expired, false otherwise

    • 重置TTL,将过期时间延长一个TTL周期 Resets TTL, extending expiration by one TTL period

      Returns void