jaguar_cache 2.1.2 copy "jaguar_cache: ^2.1.2" to clipboard
jaguar_cache: ^2.1.2 copied to clipboard

Cache layer for Jaguar.

example/jaguar_cache_example.dart

// Copyright (c) 2017, teja. All rights reserved. Use of this source code
// is governed by a BSD-style license that can be found in the LICENSE file.

import 'dart:async';
import 'package:jaguar_cache/jaguar_cache.dart';

main() async {
  final cache = new InMemoryCache(new Duration(minutes: 1));

  // Upsert
  cache.upsert('one', 1, new Duration(seconds: 5));
  print(cache.read('one'));

  // Replace
  cache.replace('one', 2, new Duration(seconds: 5));
  print(cache.read('one'));

  // Expire
  await new Future.delayed(new Duration(seconds: 5));

  try {
    cache.read('one');
  } catch (e) {
    print('Success! $e');
  }

  cache.upsert('one', 1.0, new Duration(seconds: 10));
  cache.upsert('two', 2.0, new Duration(seconds: 10));

  print(cache.readMany(['one', 'two']));

  cache.remove('one');

  try {
    cache.read('one');
  } catch (e) {
    print('Success! $e');
  }
}
0
likes
30
pub points
14%
popularity

Publisher

unverified uploader

Cache layer for Jaguar.

Repository (GitHub)
View/report issues

License

BSD-3-Clause (LICENSE)

More

Packages that depend on jaguar_cache