Flutter Auto Cache 提供了自动缓存管理,内置加密、智能替换和失效策略以及高效的大小处理。它通过自动管理数据生命周期简化持久化存储,通过加密确保安全,并在各平台上优化空间使用。非常适合需要可靠、安全且低维护成本的用户或应用数据缓存的应用程序。该包支持所有主要的 Flutter 平台,并通过简单直观的 API 实现无缝集成。
适合场景
缓存 API 响应
安全存储用户偏好
在会话之间持久化应用状态
高效管理大型数据集
通过缓存数据减少网络请求
保护敏感的本地数据
主要特点
缓存数据的自动加密
可配置的驱逐和失效策略
高效的内存和磁盘空间管理
跨平台兼容性
与现有代码的简单集成
对复杂数据类型的支持
适合对象
需要安全本地存储的应用程序
寻求自动化缓存处理的开发者
具有频繁数据持久化需求的项目
面向多个平台的应用程序
重视数据安全的团队
低维护缓存解决方案
使用建议
需要仔细配置策略以获得最佳性能
可能增加初始设置的复杂性
加密会带来轻微的开销
不适用于实时流数据
仅限键值存储模型
取决于底层文件系统的可靠性
原始 README
以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。
Introduction
Flutter Auto Cache is a sophisticated, high-tech cache manager for Flutter, designed to optimize cache management in mobile applications. Enhances cache replacement policies, provides robust encryption methods, and ensures efficient disk space management. Leveraging shared_preferences, our platform delivers a comprehensive solution for cache data management.
With Flutter Auto Cache, you can seamlessly integrate advanced cache management features, allowing you to focus on your application’s core functionality while we handle the complexities of data caching. Our user-friendly interface and powerful capabilities make Flutter Auto Cache the go-to choice for Flutter developers aiming to achieve high performance and security in their applications.
Experience unparalleled efficiency and reliability in cache management with Flutter Auto Cache.
Installation
Getting started with Flutter Auto Cache is straightforward and can be accomplished in a few simple steps. You have the flexibility to add it to your project directly from pub.dev or install it locally, depending on your development preferences and workflow.
Adding via pub.dev
To add Flutter Auto Cache to your project, run the following command:
flutter pub add flutter_auto_cache
Installing Locally
If you prefer to install Flutter Auto Cache locally, follow these steps:
Once installed, you can start using Flutter Auto Cache in your Flutter project to enhance your application's cache management with advanced features, including encryption and efficient disk space management.
Usage
To use Flutter Auto Cache, you need to initialize the cache manager before calling runApp. This ensures that all cache configurations are set up correctly. You also have the option to pass your custom initialization configuration.
import'package:flutter_auto_cache/flutter_auto_cache.dart';
Future<void> main() async {
/// Optional: Pass a custom CacheConfiguration if neededawaitAutoCacheInitializer.initialize(configuration: yourCustomConfiguration);
runApp(MyApp());
}
After initialization, you can use the cache management methods directly from the AutoCache class. Here is an example of how to access the preferences cache manager:
With this setup, you can easily manage your application's cache using the methods provided by AutoCache.
Note
Each property of the CacheConfiguration can have a different impact on how the cache behaves. It is important to understand these properties to optimize your application's performance and reliability.
Contributing
The majority of Flutter Auto Cache code is open-source. We are committed to a transparent development process and highly appreciate any contributions. Whether you are helping us fix bugs, proposing new features or improving our documentation.
Bug Report: If you see an error message or encounter an issue while using this package, please create a bug report.
Feature Request: If you have an idea or if there is a capability that is missing and would make development easier and more robust, please submit a feature request.
License
Flutter Auto Cache is licensed under the BSD-3-Clause. This license permits the redistribution and use of the software in source and binary forms, with or without modification, provided that the terms and conditions outlined in the license are met. By using Flutter Auto Cache, you agree to comply with these terms and conditions, which ensure the protection and proper use of the software.