Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/arkaung/dart_lru
A simple LRU package in Dart
https://github.com/arkaung/dart_lru
dart data-structures
Last synced: 28 days 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 (4 months ago)
- Default Branch: main
- Last Pushed: 2024-09-06T14:50:30.000Z (4 months ago)
- Last Synced: 2024-12-18T12:12:29.421Z (28 days 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
[![Pub Version](https://img.shields.io/pub/v/simple_lru_cache)](https://pub.dev/packages/simple_lru_cache)
[![Dart SDK Version](https://badgen.net/pub/sdk-version/simple_lru_cache)](https://pub.dev/packages/simple_lru_cache)
[![codecov](https://codecov.io/gh/arkaung/dart_lru/branch/main/graph/badge.svg)](https://codecov.io/gh/arkaung/dart_lru)
[![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](https://opensource.org/licenses/MIT)
[![Pub Points](https://img.shields.io/pub/points/simple_lru_cache)](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.