Skip to content
pubscout

expire_cache

2.0.1, released 5 years ago by an unverified publisher

FIFO cache with time-based expiration and mutex-like in-flight locking for async searches.

WASM-ready
$ flutter pub add expire_cache
Source repository

What it does

Provides a FIFO cache implementation where entries expire automatically according to time and size limits. It also includes mutex-like methods to prevent redundant concurrent fetches for the same cache key.

AI-written summary of version 2.0.1, based on the package's README and metadata. Report an inaccuracy

Use it when

  • You need to cache search results to avoid redundant backend requests
  • You want time-based expiration alongside a FIFO size limit
  • You need to prevent multiple concurrent operations from fetching the same key simultaneously

Skip it when

  • You need complex LRU or LFU cache eviction policies
  • You need persistent disk storage

Strengths

  • Includes built-in time-based expiration and FIFO size limits
  • Provides in-flight key tracking for mutex-like search usage

Weaknesses

  • In-memory cache only with no built-in persistence
  • Limited eviction strategies beyond FIFO

Setup

Kind
Pure Dart
Effort
Low
Code generation
No
Direct dependencies
1
final expireDuration = Duration(seconds: 120);
ExpireCache<int, int> cache = ExpireCache<int, int>(expireDuration: expireDuration, sizeLimit: 3);
cache.set(0, 0);
print(cache.get(0));

Alternatives

Packages that do the same job and could replace expire_cache.

Works with

Packages commonly used together with expire_cache: ones it builds on, ones built on it, and its own family.