increment method

int increment(
  1. String key, {
  2. int by = 1,
})

Adds by to the int under key (missing counts as 0) and returns the new value.

Implementation

int increment(String key, {int by = 1}) {
  final int next = (get<int>(key) ?? 0) + by;
  _put(key, next, _expiry[key]);
  unawaited(_schedule());
  return next;
}