Skip to content

Instantly share code, notes, and snippets.

@sgl0v
Created November 3, 2019 18:14
Show Gist options
  • Save sgl0v/59e74c2616fa11ca02ff252e01d68b2b to your computer and use it in GitHub Desktop.
Save sgl0v/59e74c2616fa11ca02ff252e01d68b2b to your computer and use it in GitHub Desktop.
// Declares in-memory image cache
protocol ImageCacheType: class {
// Returns the image associated with a given url
func image(for url: URL) -> UIImage?
// Inserts the image of the specified url in the cache
func insertImage(_ image: UIImage?, for url: URL)
// Removes the image of the specified url in the cache
func removeImage(for url: URL)
// Removes all images from the cache
func removeAllImages()
// Accesses the value associated with the given key for reading and writing
subscript(_ url: URL) -> UIImage? { get set }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment