/cache-manager-flutter

Cache Manager using GetStorage with time expiration

Primary LanguageDartMIT LicenseMIT

Cache Manager Flutter

Cache Manager using GetStorage with time expiration.

This is based on @ozkayas's code.

Used Packages

To use this file, you need to be using:

So, to add them to the project, you just need to run:

flutter pub add get

and

flutter pub add get_storage

Example

You need to save some data for some time

To use, you just have to declare the class like this:

class ... extends GetxController with CacheManager { 

}

and then, when you need, just call the function you need:

Save

saveValue(value, CacheManagerKey.userToken)

Get a value by key

getValueFrom(CacheManagerKey.userToken) 

Remove value by key

removeValueFrom(CacheManagerKey.userToken)

Remove all cached data

removeAllCacheData()

Check if it is expired

isValid(ExpirationTime.inDays, 3, savedValue.lastSaved)