increment abstract method

Future<int> increment(
  1. String key, {
  2. int by,
  3. Duration? ttl,
})

Adds by to the number at key and returns the new total, creating it at by when it is absent.

ttl is how long the counter lives from this call. A caller counting per window puts the window in the key, so an expiry that lands late costs nothing: the next window is a different key.

Implementation

Future<int> increment(String key, {int by, Duration? ttl});