https://github.com/arkaung/dart_lru
A simple LRU package in Dart
https://github.com/arkaung/dart_lru
dart data-structures
Last synced: 4 months ago
JSON representation
A simple LRU package in Dart
- Host: GitHub
- URL: https://github.com/arkaung/dart_lru
- Owner: ArkAung
- License: mit
- Created: 2024-09-05T10:37:24.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-09-06T14:50:30.000Z (almost 2 years ago)
- Last Synced: 2025-04-05T06:29:12.729Z (about 1 year ago)
- Topics: dart, data-structures
- Language: Dart
- Homepage: https://arkaung.github.io/dart_lru/
- Size: 26.4 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Simple LRU Cache
[](https://pub.dev/packages/simple_lru_cache)
[](https://pub.dev/packages/simple_lru_cache)
[](https://codecov.io/gh/arkaung/dart_lru)
[](https://opensource.org/licenses/MIT)
[](https://pub.dev/packages/simple_lru_cache/score)
A simple and efficient Least Recently Used (LRU) cache implementation in Dart.
## Features
- Fixed-size cache with LRU eviction policy
- Generic key-value storage
- O(1) complexity for get, put, and remove operations
## Usage
```dart
import 'package:simple_lru_cache/simple_lru_cache.dart';
void main() {
final cache = LRUCache(3);
cache.put(1, 'one');
cache.put(2, 'two');
cache.put(3, 'three');
print(cache.get(1)); // Outputs: one
cache.put(4, 'four'); // This will evict the least recently used item (2)
print(cache.containsKey(2)); // Outputs: false
}
```
## Installation
Add this to your package's `pubspec.yaml` file:
```yaml
dependencies:
simple_lru_cache: ^0.2.1
```
Then run `dart pub get`.
## License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.