Skip to content
pubscout

memory_cache

1.2.0, released 4 years ago by gokberk.dev

A simple, fast and global in-memory cache with CRUD features.

WASM-ready
$ flutter pub add memory_cache
Source repository

What it does

Memory Cache allows developers to create, read, update, delete, and invalidate cache entries directly in memory. It supports expirable cache entries with custom durations and allows creating local MemoryCache instances alongside the global instance.

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

Use it when

  • You need a fast, temporary in-memory key-value store.
  • You want to cache data with an optional expiration duration.
  • You need either a global cache or local cache instances.

Skip it when

  • You need data to persist across app restarts (use local storage instead).
  • You need complex querying capabilities like SQL databases.

Strengths

  • Simple and fast CRUD operations
  • Supports expirable cache entries using Durations
  • Supports both global instance and local instances

Weaknesses

  • Data is lost when the app restarts since it is strictly in-memory
  • Lacks advanced querying or indexing features

Setup

Kind
Pure Dart
Effort
Low
Code generation
No
Direct dependencies
0

not documented

MemoryCache.instance.create('myKey', 'myValue', expiry: const Duration(seconds: 5));
final myValue = MemoryCache.instance.read<String>('myKey');

Alternatives

Packages that do the same job and could replace memory_cache.

  • shared_preferences

    Pick shared_preferences if you need key-value storage that persists across app restarts.

  • hive_ce

    Pick hive_ce if you need a fast NoSQL database solution for local data persistence.