     }
     
     public func memoryCachedImage(withURL url: URL) -> Image? {
+        assert(Thread.isMainThread)
         let identifier = identifierForURL(url) as NSString
         return memoryCache.object(forKey: identifier)
     }
     
     public func addToMemoryCache(_ image: Image, url: URL) {
+        assert(Thread.isMainThread)
         let identifier = identifierForURL(url) as NSString
         memoryCache.setObject(image, forKey: identifier, cost: Int(image.staticImage.size.width * image.staticImage.size.height))
     }

        guard let image = createImage(data: data, mimeType:typedData.MIMEType) else {
            return nil
        }
        addToMemoryCache(image, url: url)
        return image
    }
    

        guard let image = createImage(data: data, mimeType: typedDiskData.MIMEType) else {
            return nil
        }
        DispatchQueue.main.async {
            self.addToMemoryCache(image, url: url)
        }
        return image
    }
    
