flutter_memory_cache_plus 0.0.2 copy "flutter_memory_cache_plus: ^0.0.2" to clipboard
flutter_memory_cache_plus: ^0.0.2 copied to clipboard

`flutter_memory_cache` is a lightweight and customizable in-memory cache solution for Flutter applications. It supports various caching strategies such as LRU (Least Recently Used), FIFO (First In Fir [...]

flutter_memory_cache #

flutter_memory_cache is a lightweight and customizable in-memory cache solution for Flutter applications. It supports various caching strategies such as LRU (Least Recently Used), FIFO (First In First Out), and LFU (Least Frequently Used). With easy-to-set TTL (Time To Live) options, it helps optimize performance by reducing frequent network or database requests.

Features #

  • Multiple Caching Strategies: Choose between LRU, FIFO, or LFU to suit your use case.
  • TTL (Time To Live): Set expiration time for cache entries.
  • High Performance: Efficient memory management to keep your app running smoothly.
  • Flexible: Easy to configure to meet different caching needs.

Getting Started #

Prerequisites #

  • Dart SDK 2.12+
  • Flutter 2.0+

To use this package, include it in your pubspec.yaml file:

dependencies:
  flutter_memory_cache: ^0.0.1

Usage #

To use flutter_memory_cache, follow these steps:

  1. Add the dependency: Run the following command to get the package:

    flutter pub get
    
  2. Usage Example:

    import 'package:flutter_memory_cache/flutter_memory_cache.dart';
    
    void main() {
      // Create a cache with a capacity of 3 entries and LRU strategy
      final cache = Cache<String, String>(
        capacity: 3,
        ttl: Duration(seconds: 5),
        policy: LRU(),
      );
    
      cache.put('key1', 'value1');
      cache.put('key2', 'value2');
      cache.put('key3', 'value3');
    
      print(cache.get('key1')); // Output: value1
    
      Future.delayed(Duration(seconds: 6), () {
        print(cache.get('key1')); // Output: null (key1 has expired)
      });
    }
    
  3. Supported Policies:

    • LRU (Least Recently Used): Removes the least recently accessed item when the capacity limit is reached.
    • FIFO (First In First Out): Removes the earliest added item when the capacity limit is reached.
    • LFU (Least Frequently Used): Removes the least frequently accessed item when the capacity limit is reached.
  4. Additional Information:

    For more details, examples, and contribution guidelines, please refer to the GitHub repository. Feel free to raise issues and suggest new features. Contributions are welcome!

2
likes
120
points
37
downloads

Publisher

unverified uploader

Weekly Downloads

`flutter_memory_cache` is a lightweight and customizable in-memory cache solution for Flutter applications. It supports various caching strategies such as LRU (Least Recently Used), FIFO (First In First Out), and LFU (Least Frequently Used). With easy-to-set TTL (Time To Live) options, it helps optimize performance by reducing frequent network or database requests.

Documentation

API reference

License

MIT (license)

Dependencies

flutter

More

Packages that depend on flutter_memory_cache_plus