Search code examples
apache-flinkflink-streaming

MapState updateTtlOnReadAndWrite based on keys or values?


With a MapState and TTL config set to updateTtlOnReadAndWrite(), is the TTL updated when a key is read (e.g. calling map.keys()) or only when the value associated is retrieved?


Solution

  • When updateTtlOnReadAndWrite() is called, api like contains() will update the TTL of the associated value, even though we do not touch the value. For api keys(), the TTL will be updated when the iterator accesses those keys. TTL of values for keys not being touched by the iterator won't be updated.