v0.3.0
ttl_cache
ユーザーが定義した生存時間(TTL)後にエントリが期限切れになるシンプルなキー値ストア
3いいね 10.3万30日間ダウンロード160Pub ポイント
AndroidiOSLinuxmacOSWebWindows
エントリの有効期限付きのシンプルなキー値ストア
以下は英語原文のスナップショットです。最新版は GitHub をご覧ください。
A simple Dart key-value store with optional entry expiration.
A simple usage example:
import 'package:ttl_cache/ttl_cache.dart';
void main() {
final cache = TtlCache<String, int>(defaultTtl: Duration(seconds: 1));
// Set 'a' and 'b' with a default TTL of 1 second.
// These lines are equivalent.
cache['a'] = 1;
cache.set('b', 2);
// Set 'c' with a TTL of 3 seconds.
cache.set('c', 3, ttl: Duration(seconds: 3));
// Set 'd' with no TTL. This entry will remain in the cache until it is
// manually removed.
cache.set('d', 4, ttl: null);
print(cache['a']); // 1
print(cache['b']); // 2
print(cache['c']); // 3
print(cache['d']); // 4
// Entries with the default TTL will have expired. 'c' has a TTL of 3 seconds
// and will still be available.
Future.delayed(Duration(seconds: 2), () {
print(cache['a']); // null
print(cache['b']); // null
print(cache['c']); // 3
print(cache['d']); // 4
});
// All entries from above with TTLs will have expired. 'd' has no TTL and will
// still be available.
Future.delayed(Duration(seconds: 4), () {
// 'a' and 'b' will still be null
print(cache['c']); // null
print(cache['d']); // 4
});
}
依存関係一覧 3 件
^1.1.1^1.19.2>=5.0.0 <12.0.0用途で絞り込み、開発状況を比較し、採用前に元のリポジトリで要件を確認しましょう。
“A repository is the most basic element of GitHub.”
GitHub Docs — About repositories ↗