mcache 1.0.2 copy "mcache: ^1.0.2" to clipboard
mcache: ^1.0.2 copied to clipboard

Tools for caching values in memory. Supports setting the expiration of values.

example/README.md

Languages:

English Russian

Save values to cache:

void main(List<String> args) {
  var cache = Cache(deleteOnExpire: false);

  cache.set('name', 'Alex');

  cache.set('key', '1o23fjadijs');
}

Save and retrieve values from cache:

void main(List<String> args) {
  var cache = Cache(deleteOnExpire: false);

  cache.set('name', 'Alex');

  cache.set('key', '1o23fjadijs');

  print(cache['name']);

  print(cache['key']);
}

Save values and specify a lifetime for them:

void main(List<String> args) {
  var cache = Cache(checkPeriod: const Duration(seconds: 1));

  cache.set('name', 'Alex',
      expirationSetting:
          ExpirationSetting(expiration: const Duration(seconds: 3)));

  cache.set('key', '1o23fjadijs',
      expirationSetting:
          ExpirationSetting(expiration: const Duration(seconds: 3)));

  print(cache['name']);

  print(cache['key']);

  Future.delayed(const Duration(seconds: 4), () {
    print(cache['name']);

    print(cache['key']);

    cache.dispose();
  });
}

Записать значения и удалить их все:

void main(List<String> args) {
  var cache = Cache(deleteOnExpire: false);

  cache.set('name', 'Alex');

  print(cache['name']);

  cache.clear();

  print(cache['name']);
}
0
likes
130
pub points
44%
popularity

Publisher

verified publisherbatykov-gleb.ru

Tools for caching values in memory. Supports setting the expiration of values.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

More

Packages that depend on mcache