An open API service indexing awesome lists of open source software.

https://github.com/thekeenant/mocha

:coffee: A caching library for Dart inspired by Guava.
https://github.com/thekeenant/mocha

cache dart dartlang library

Last synced: about 1 year ago
JSON representation

:coffee: A caching library for Dart inspired by Guava.

Awesome Lists containing this project

README

          

# 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:

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

Future 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(
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][tracker].

[tracker]: https://github.com/thekeenant/mocha