Skip to content

cxp108/flutter_memory_cache

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Language: English | 中文简体

flutter_memory_cache

flutter memory cache in Map with ttl support.

Notice

  • It's not for the logical cache because eviction will automatically remove cache.
  • It use TTL(Time To Live) to make sure data can be refresh.
  • This lib have NOT been fully tested yet, Please do NOT use it in production.

Getting Started

Add dependency

dependencies:
   flutter_memory_cache: #latest version

then

main(){
 MemoryCache memoryCache = MemoryCache();
 dynamic cache1 = {'name': 'obj1'};
 var cache2 = {'name': 'obj2'};
 memoryCache.put('obj1', cache1); //default ttl 60 seconds
 memoryCache.putWithTTL(
     'cache2', cache2, 5); //cache2 will be invalidate in 5 seconds
 sleep(Duration(seconds:6));
 var ret = memoryCache.get('cache2');//ret is null
 print('ret is $ret');
 ret = memoryCache.get('cache1');
 print('cache1 is $ret'); // cache1 is {name: obj1}
}

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages