搜尋套件、儲存庫與 APP 分類

套件詳情v1.2.0

memory_cache

記憶體快取是簡單、快速且全域的記憶體快取,具備 CRUD 功能。

AndroidiOSWebmacOSWindowsLinux
近 30 天下載
4920
喜歡數
36
Pub 分數
160

安裝套件

flutter pub add memory_cache

套件介紹

根據套件公開資料產生的選型評估,僅供參考。

Memory Cache 是一個輕量級、高效率的記憶體快取解決方案,適用於 Flutter 應用程式。它提供簡單的 CRUD(建立、讀取、更新、刪除)操作,可在不同平台間暫時儲存和取得資料。設計為追求速度與簡潔,它在應用程式內全域運作,非常適合快取 API 回應、使用者偏好或任何需要快速存取的暫時資料。該快取不會在應用程式重新啟動後持續存在,確保其適合暫時儲存需求。

適用情境

  • 快取 API 回應
  • 儲存使用者會話資料
  • 臨時狀態管理
  • 優化重複的資料取得
  • 減少網路呼叫
  • 快速本地數據檢索

主要特色

  • 簡單的 CRUD 操作
  • 全局快取實例
  • 高性能
  • 跨平台支援
  • 無持久性
  • 與 Flutter 的輕鬆整合

適合對象

  • 需要快速記憶體儲存的開發人員
  • 頻繁資料查詢的應用程式
  • 原型設計與測試
  • 輕量級快取,無依賴
  • 臨時數據處理

使用建議

  • 數據在應用重啟後遺失
  • 不適用於持久儲存
  • 受限於記憶體容量
  • 無內建過期策略
  • 不適用於大型資料集

原始 README

以下為關聯原始碼儲存庫的 README 原文快照,最新內容請造訪原始碼儲存庫。

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();

所屬分類

原始碼儲存庫

使用此套件的專案