hope_cache 0.1.5
hope_cache: ^0.1.5 copied to clipboard
Simple and fast caching for Dart/Flutter with TTL support, multiple eviction strategies, and pluggable storage.
// ignore_for_file: avoid_print
import 'package:hope_cache/cache_manager.dart';
/// Hope Cache Examples
///
/// See other examples in this directory:
/// - basic_usage.dart → basic set/get/invalidate
/// - ttl_configuration.dart → per-key TTL overrides
/// - eviction_policies.dart → LRU, LFU, FIFO
/// - custom_storage.dart → pluggable storage backends
/// - map_key.dart → React Query-style map keys
/// - query.dart → advanced querying
void main() async {
final cache = await CacheManager.create(
maxSize: 1024 * 1024,
defaultTTL: Duration(minutes: 5),
evictionPolicy: EvictionPolicy.lru,
);
await cache.set('hello', 'world');
final value = await cache.getIfPresent('hello');
print('hope_cache works! → $value');
}