Search packages, repositories and app categories

Package detailsv1.2.0

memory_cache

Memory Cache is simple, fast and global in-memory cache with CRUD features.

AndroidiOSWebmacOSWindowsLinux
30-day downloads
4.9K
Likes
36
Pub points
160

Install package

flutter pub add memory_cache

Package Overview

Package selection guidance compiled from public package information, community data, and project usage.

Memory Cache is a lightweight, high-performance in-memory caching solution for Flutter applications. It provides simple CRUD (Create, Read, Update, Delete) operations to store and retrieve data temporarily across different platforms. Designed for speed and simplicity, it operates globally within the app, making it ideal for caching API responses, user preferences, or any transient data that needs fast access. The cache is not persisted across app restarts, ensuring it remains suitable for temporary storage needs.

Use cases

  • Caching API responses
  • Storing user session data
  • Temporary state management
  • Optimizing repeated data fetches
  • Reducing network calls
  • Fast local data retrieval

Key features

  • Simple CRUD operations
  • Global cache instance
  • High performance
  • Cross-platform support
  • No persistence
  • Easy integration with Flutter

Suitable for

  • Developers needing fast in-memory storage
  • Apps with frequent data lookups
  • Prototyping and testing
  • Lightweight caching without dependencies
  • Temporary data handling

Considerations

  • Data is lost on app restart
  • Not suitable for persistent storage
  • Limited to memory capacity
  • No built-in expiration policies
  • Not designed for large datasets

Original README

Original README snapshot from the linked source repository. Visit the repository for the latest content.

Memory Cache

Memory Cache is simple, fast and global in-memory cache.

Features

  • Create, read, update, delete and invalidate cache.
  • Expirable Cache
  • Creating local MemoryCache instance.

Getting started

Use this package as a Library

Depend On it

Run this command

with Dart:

$ dart pub add memory_cache

with Flutter:

$ flutter pub add memory_cache

This will add a line like this to your package's pubspec.yaml (and run an implicit dart pub get or flutter pub get):

dependencies:
  memory_cache: ^1.2.0

Usage

Create New Value
MemoryCache.instance.create('myKey', 'myValue');

with Expiry:

MemoryCache.instance.create(
    'myKey',
    'myValue',
    expiry: const Duration(seconds: 5),
  );
Read Value
final myValue = MemoryCache.instance.read<String>('myKey');
Update Value
MemoryCache.instance.update('myKey', 'myUpdatedValue');
Delete Value
MemoryCache.instance.delete('myKey');
Local Instance

MemoryCache can be created locally and same features will be supported

final MemoryCache localCache = MemoryCache();

Categories

Source repository

Projects using this package