Skip to content

Commit

Permalink
Merge pull request onevcat#823 from SlinToWin/master
Browse files Browse the repository at this point in the history
Add option to remove image only from disk cache and not memory
  • Loading branch information
onevcat authored Dec 6, 2017
2 parents 71bf02d + 37b3d39 commit e3f3594
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions Sources/ImageCache.swift
Original file line number Diff line number Diff line change
Expand Up @@ -234,16 +234,21 @@ open class ImageCache {
- parameter key: Key for the image.
- parameter identifier: The identifier of processor used. If you are using a processor for the image, pass the identifier of processor to it.
This identifier will be used to generate a corresponding key for the combination of `key` and processor.
- parameter fromDisk: Whether this image should be removed from disk or not. If false, the image will be only removed from memory.
- parameter fromMemory: Whether this image should be removed from memory or not. If false, the image won't be removed from memory.
- parameter fromDisk: Whether this image should be removed from disk or not. If false, the image won't be removed from disk.
- parameter completionHandler: Called when removal operation completes.
*/
open func removeImage(forKey key: String,
processorIdentifier identifier: String = "",
fromMemory: Bool = true,
fromDisk: Bool = true,
completionHandler: (() -> Void)? = nil)
{
let computedKey = key.computedKey(with: identifier)
memoryCache.removeObject(forKey: computedKey as NSString)

if fromMemory {
memoryCache.removeObject(forKey: computedKey as NSString)
}

func callHandlerInMainQueue() {
if let handler = completionHandler {
Expand Down

0 comments on commit e3f3594

Please sign in to comment.