CollectionTTL object API reference
This object is passed into API methods to say whether a TTL should be updated and if so, what the new TTL value should be.
This tries to make the process more intuitive by providing named constructors and copiers for various situations.
See Expire Data with TTL for more information on how TTL works with Momento Cache.
Common method behaviors
- If a CollectionTTL is not passed in a function call, a default value of
CollectionTtl.fromCacheTtl()will be used. This value is the TTL configured on the cache client.
- The TTL for the collection will be refreshed any time the collection is modified.
- ttl: duration - (optional)
- If no TTL is given, the TTL set in the current client connection object is used.
- refreshTtl: boolean = true
- If set to true, the collection’s TTL will be reset to the provided value.
- If set to false, the existing TTL set on the item is retained.
- fromCacheTtl(): CollectionTtl - uses the client’s TTL, equivalent to
- of(ttl: duration): CollectionTtl - equivalent to
- refreshTtlIfProvided(ttl?: duration): CollectionTtl - if a value is provided, it will refresh the item's TTL. If no value is provided, it will not refresh the TTL.
- ttlSeconds(): duration - Returns the TTL in seconds
- ttlMilliseconds(): duration - Returns the TTL in milliseconds
- refreshTtl(): boolean - Sets if the TTL should be refreshed when the item is modified
- withRefreshTtlOnUpdates(): CollectionTtl - a copy, but refresh is true
- withNoRefreshTtlOnUpdates(): CollectionTtl - a copy, but refresh is false
- toString(): displays the TTL in seconds and the refreshTtl configuration