Your go-to solution for efficient caching in Dart
Store and retrieve data quickly with our optimized LRU caching mechanism.
Easy-to-use API that integrates seamlessly into your Dart applications.
Automatically evicts the least recently used items to manage memory effectively.
To use the LRU Cache package, add it to your pubspec.yaml
file:
dependencies: simple_lru_cache: ^0.2.0
Here’s a simple example of how to use the LRU Cache:
import 'package:simple_lru_cache/simple_lru_cache.dart';
void main() {
final cache = LRUCache(2);
cache.put(1, 'one');
cache.put(2, 'two');
print(cache.get(1)); // Outputs: one
cache.put(3, 'three'); // Evicts key 2
print(cache.get(2)); // Exception thrown
}