canister 1.2.2 copy "canister: ^1.2.2" to clipboard
canister: ^1.2.2 copied to clipboard

A versatile and extensible caching library written in pure Dart, offering Guava-like caching capabilities.

Canister - A Versatile Dart Caching Library #

GitHub Workflow Status Pub Version (including pre-releases) Pub Points Pub Likes

Canister is a powerful and extensible caching library for Dart, offering a wide range of caching strategies and features to enhance the performance of your Dart applications. Whether you need to reduce latency, optimize data retrieval, or implement memoization, Canister has you covered.

Features #

  • Extensible: Customize and extend Canister to tailor caching strategies to your specific needs.
  • Guava-Like Caches: Familiar caching patterns inspired by Guava's caching library.
  • Lazy Computations: Easily make your existing functions compute lazily.
  • Asynchronous Caching: Seamlessly handle asynchronous operations for modern Dart applications.
  • Memoization: Efficiently cache function results to eliminate redundant computations.
  • Expiration Policies: Configure expiration rules based on write or read operations.
  • Weight Functions: Assign weights to cache entries for advanced cache management.
  • Removal Listeners: Trigger actions when cache entries are removed, adding flexibility and functionality.

Installation #

Add the following dependency to your pubspec.yaml:

dependencies:
  canister: ^1.0.0

Usage #

import 'package:canister/canister.dart';

void main() {
  // Create and configure a cache
  final cache = CacheBuilder<String, int>()
      .capacity(100)
      .expireAfterWrite(Duration(minutes: 30))
      .build();

  // Put a value into the cache
  cache.put('key', 42);

  // Get a value from the cache
  final value = cache.get('key');
  print('Cached Value: $value');
}

Fore more examples, have a look at the example folder.

Contributing #

Contributions are welcome! If you find any issues or have suggestions for improvement, please open an issue or submit a pull request on our GitHub repository.

4
likes
130
pub points
32%
popularity

Publisher

verified publisherhelight.dev

A versatile and extensible caching library written in pure Dart, offering Guava-like caching capabilities.

Repository (GitHub)
View/report issues

Topics

#cache #caching #lazy #lru #memoized

Documentation

API reference

License

Apache-2.0 (LICENSE)

Dependencies

meta

More

Packages that depend on canister