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.
- Host: GitHub
- URL: https://github.com/thekeenant/mocha
- Owner: thekeenant
- License: mit
- Created: 2017-05-19T22:27:20.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2019-08-28T01:23:11.000Z (almost 7 years ago)
- Last Synced: 2025-03-27T03:35:18.330Z (over 1 year ago)
- Topics: cache, dart, dartlang, library
- Language: Dart
- Homepage:
- Size: 7.81 KB
- Stars: 5
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
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