Proyectos de Subversion Iphone Microlearning - Inconcert

Rev

Autoría | Ultima modificación | Ver Log |

//
//  ImageCache.swift
//  twogetskills
//
//  Created by Efrain Yanez Recanatini on 3/9/22.
//

import DataCache

class ImageCache {
    
    public let cache :  DataCache
    
    static let sharedInstance: ImageCache = {
           let instance = ImageCache()
           
           // setup code
           return instance
    }()
    
    init() {
        cache = DataCache(name: "2GetSkillsCustomCache")
        cache.maxDiskCacheSize = 600*1024*1024      // 100 MB
        cache.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 items
        cache.totalCostLimit = 1024 * 1024 * 600 // 600 MB
        return cache
    }()
}
 */