simple_cache

Last updated:

0 purchases

simple_cache Image
simple_cache Images
Add to Cart

Description:

simple cache

simple_cache #
A flutter plugin for cache, simple and extendible
Usage: #
Add dependency: #
Please check the latest version before installation.
dependencies:
flutter:
sdk: flutter
# add simple_cache
simple_cache: ^0.0.3
copied to clipboard
Add the following imports to your Dart code: #
import 'package:simple_cache/simple_cache.dart';
copied to clipboard
How to use #
/// set cache
void setExCache() async{
String cacheKey = 'simple.cache.key';
String value = 'simple cache value';
SimpleCache simpleCache = await SimpleCache.getInstance();
await simpleCache.setEx(cacheKey, value, expire: expire);
}

/// get cache
String getExCache(){
String cacheKey = 'simple.cache.key';
SimpleCache simpleCache = SimpleCache.getInstance();
return simpleCache.getEx(cacheKey);
}

/// set map
void setMapCache() async{
String cacheKey = 'simple.map.cache.key';
Map value = {
'id': 1,
'name': 'simple cache',
};
SimpleCache simpleCache = await SimpleCache.getInstance();
await simpleCache.setMap(cacheKey, value);
}

/// get map
Map getMapCache(){
String cacheKey = 'simple.map.cache.key';
SimpleCache simpleCache = SimpleCache.getInstance();
return simpleCache.getMap(cacheKey);
}

/// set list map
void setListMapCache() async{
String cacheKey = 'simple.list.map.cache.key';
List<Map> value = [
{
'id': 1,
'name': 'simple cache',
}
];
SimpleCache simpleCache = await SimpleCache.getInstance();
await simpleCache.setMap(cacheKey, value);
}

/// get list map
List<Map> getListMapCache(){
String cacheKey = 'simple.list.map.cache.key';
SimpleCache simpleCache = SimpleCache.getInstance();
return simpleCache.setListMap(cacheKey);
}
copied to clipboard
example: #
example demo
effect:

License:

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.