AutorÃa | Ultima modificación | Ver Log |
//// ImageCache.swift// twogetskills//// Created by Efrain Yanez Recanatini on 3/9/22.//import DataCacheclass ImageCache {public let cache : DataCachestatic let sharedInstance: ImageCache = {let instance = ImageCache()// setup codereturn instance}()init() {cache = DataCache(name: "2GetSkillsCustomCache")cache.maxDiskCacheSize = 600*1024*1024 // 100 MBcache.maxCachePeriodInSecond = 7*86400 // 1 week}}//import UIKit/*protocol ImageCache {subscript(_ key: NSString) -> UIImage? { get set }}struct TemporaryImageCache: ImageCache {subscript(key: NSString) -> UIImage? {get {cache.object(forKey: key as NSString)}set {newValue == nil ? cache.removeObject(forKey: key as NSString) : cache.setObject(newValue!, forKey: key as NSString)}}private let cache: NSCache<NSString, UIImage> = {let cache = NSCache<NSString, UIImage>()cache.countLimit = 100 // 100 itemscache.totalCostLimit = 1024 * 1024 * 600 // 600 MBreturn cache}()}*/