sjwiesman commented on a change in pull request #123: URL: https://github.com/apache/flink-statefun/pull/123#discussion_r433266820
########## File path: docs/sdk/java.md ########## @@ -364,6 +364,47 @@ PersistedTable<String, Integer> table = PersistedTable.of("my-table", String.cla PersistedAppendingBuffer<Integer> buffer = PersistedAppendingBuffer.of("my-buffer", Integer.class); {% endhighlight %} +### State Expiration + +Persisted states may be configured to expire and be deleted after a specified duration. +This is supported by all types of state: + +{% highlight java %} +@Persisted +PersistedValue<Integer> table = PersistedValue.of( + "my-value", + Integer.class, + Expiration.expireAfterWriting(Duration.ofHours(1))); + +@Persisted +PersistedTable<String, Integer> table = PersistedTable.of( + "my-table", + String.class, + Integer.class, + Expiration.expireAfterWriting(Duration.ofMinutes(5))); + +@Persisted +PersistedAppendingBuffer<Integer> buffer = PersistedAppendingBuffer.of( + "my-buffer", + Integer.class, + Expiration.expireAfterWriting(Duration.ofSeconds(30))); +{% endhighlight %} + +There are two expiration modes supported: + +{% highlight java %} +Expiration.expireAfterWriting(...) + +Expiration.expireAfterReadingOrWriting(...) +{% endhighlight %} + +The above modes differ in when expiration timers for the state will be registered, either only on writes or on both reads and writes. + +These timers will also be persisted as managed state. This allows the timers to still be effectively running while the application is down. Review comment: > State TTL configurations are made fault-tolerant by the runtime. In the case of downtime, state entries that should have been removed during said downtime will be purged immediately on restart. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org