quick_cache_flutter 2.0.1 copy "quick_cache_flutter: ^2.0.1" to clipboard
quick_cache_flutter: ^2.0.1 copied to clipboard

Manage your cache securely with a single line of code , without sacrificing performance.

πŸš€ Quick Cache Flutter #

Breaking Changes

The method QuickCacheFlutter.instance.init is deprecated.
Use QuickCacheFlutter.init instead.

Features #

Manage your cache securely with a single line of code, without sacrificing performance.

⚑ Fast - uses Hive underneath for peak performance.

πŸ”’ Secure - Encrypts everything you save.

⏲️ Expiry Duration - You can provide a stale period for each key.

πŸ˜‰ Easy to use - Single line read write.

🧹 Active and passive cleaning - Automatically removes expired cache entries in the background while allowing manual cleanup when needed.

⏳ Global Expiry Duration - Set a default expiration time for all cache entries, ensuring automatic cleanup without needing to specify expiry for each key.

Getting started #

You have to initialize QuickCacheFlutter before runApp(Widget) (Call it after WidgetsFlutterBinding.ensureInitialized()):

void main() {
  WidgetsFlutterBinding.ensureInitialized();
  QuickCacheFlutter.init(
      globalCacheSettingParams: GlobalCacheSettingParams(
          activeCleaning: true,
          globalExpiryDuration: const Duration(minutes: 5),
          maxCacheSize: 5000)); // maxCacheSize is in bytes.
  runApp(const MyApp());
}

GlobalCacheSettingParams #

This version introduces GlobalCacheSettingParams, which aims to provide an easy way to manage settings while initializing cache.

🧼 activeCleaning - When set to true, expired cache entries are automatically cleaned up in the background to free up space and maintain performance.

⏳ globalExpiryDuration - Defines a default expiration time for all cache entries. If no expiry is specified for an individual key, this duration will be used instead. if globalExpiryDuration is not specified and expiryDuration is also not specified then key will remain in memory until it is manually deleted or cleaned if maxCacheSize exceeds.

πŸ“¦ maxCacheSize - Sets the maximum allowable cache size (in bytes). Once this limit is reached, older cache entries will be removed to make space for new ones by using LFU policy.

Usage #

πŸ“– QuickCacheFlutter.instance.readCache - Reads the value for given key

✍️ QuickCacheFlutter.instance.setCache - Save a single key value in database.

🧹 QuickCacheFlutter.instance.removeAllCache - Clear all cache from database.

πŸ—‘οΈ QuickCacheFlutter.instance.deleteValue -Deletes a single value.

If expiryDuration is not provided or set to null then the value will persist for app lifetime or till it is manually deleted.

QuickCacheFlutter.instance.setCache(
                    key: 'key',
                    value: value,
                    expiryDuration: const Duration(seconds: 20));

Additional information #

Feedbacks, issues, contributions and suggestions are more than welcomed! 😁

Connect with me #

πŸ‘‰ LinkedIn

πŸ‘‰ X (twitter)

8
likes
150
points
59
downloads

Publisher

verified publisherappflo.dev

Weekly Downloads

Manage your cache securely with a single line of code , without sacrificing performance.

Repository (GitHub)
View/report issues

Documentation

Documentation
API reference

License

BSD-3-Clause (license)

Dependencies

flutter, flutter_secure_storage, hive, hive_flutter, path_provider

More

Packages that depend on quick_cache_flutter