mocha 0.0.2 copy "mocha: ^0.0.2" to clipboard
mocha: ^0.0.2 copied to clipboard

Dart 1 only

A simple caching library.

mocha #

Mocha is a simple caching library for Dart.

Features

  • Size-based eviction
  • Time-based expiration (since last write)
  • Asynchronously refresh values
  • Automatic asynchronous loading of values into the cache
  • Manually...
    • Evict/invalidate values
    • Populate the cache

Usage #

A simple usage example:

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

Future<String> expensiveOperation(int key) async {
  // pretend this is takes time to calculate
  var sq = key * key;
  return '$key^2 = $sq';
}

main() async {
  var cache = new LoadingCache<int, String>(
    expensiveOperation,
    maximumSize: 10,
    expiresAfterWrite: const Duration(minutes: 1)
  );

  print(await cache.get(4));
}

Features and bugs #

Please file feature requests and bugs at the issue tracker.

0
likes
20
pub points
0%
popularity

Publisher

unverified uploader

A simple caching library.

Repository (GitHub)
View/report issues

License

MIT (LICENSE)

More

Packages that depend on mocha