Skip to content

Key/value memory cache convenience library for Swift.

License

Notifications You must be signed in to change notification settings

vinayakathawle/DataLoader

 
 

Repository files navigation

DataLoader

license Travis Codecov codebeat badge Twitter

This is a key/value memory cache convenience library for Swift.With DataLoader you can mantain your data loaded cached during an operation that sometimes requires you manage the state loaded and not loaded.

Inspired on the opensource facebook/dataloader library.

Instalation

Carthage

     github "LucianoPAlmeida/DataLoader" ~> 0.3.0  

CocoaPods

       pod 'DataLoader', '~> 0.3.0'     

Usage

   var loader: DataLoader<Int, Int>!
   // Creating the loader object.
   loader = DataLoader(loader: { (key, resolve, reject) in
       //load data from your source (can be a file, or a resource from server, or an heavy calculation)
       Fetcher.data(value: key, { (value, error) -> Void in 
           if let error = error {
               reject(error)
           } else {
               resolve(value)
           }
       })
   })
   
   //Using the loader object. 
   loader.load(key: 6) { (result) in
     //do your stuff with data
   }
   
   //Clear data from cache
   loader.cache.remove(key: 6) 
   
   //or 
   
   loader.cache.clear()
   

Licence

DataLoader is released under the MIT License.

About

Key/value memory cache convenience library for Swift.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Swift 86.8%
  • Ruby 10.7%
  • Objective-C 2.5%