|
@@ -588,6 +588,15 @@ open class ImageCache {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// MARK: Cleaning
|
|
// MARK: Cleaning
|
|
|
|
|
+ /// Clears the memory & disk storage of this cache. This is an async operation.
|
|
|
|
|
+ ///
|
|
|
|
|
+ /// - Parameter handler: A closure which is invoked when the cache clearing operation finishes.
|
|
|
|
|
+ /// This `handler` will be called from the main queue.
|
|
|
|
|
+ public func clearCache(completion handler: (() -> Void)? = nil) {
|
|
|
|
|
+ clearMemoryCache()
|
|
|
|
|
+ clearDiskCache(completion: handler)
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
/// Clears the memory storage of this cache.
|
|
/// Clears the memory storage of this cache.
|
|
|
@objc public func clearMemoryCache() {
|
|
@objc public func clearMemoryCache() {
|
|
|
try? memoryStorage.removeAll()
|
|
try? memoryStorage.removeAll()
|
|
@@ -597,7 +606,7 @@ open class ImageCache {
|
|
|
///
|
|
///
|
|
|
/// - Parameter handler: A closure which is invoked when the cache clearing operation finishes.
|
|
/// - Parameter handler: A closure which is invoked when the cache clearing operation finishes.
|
|
|
/// This `handler` will be called from the main queue.
|
|
/// This `handler` will be called from the main queue.
|
|
|
- open func clearDiskCache(completion handler: (()->())? = nil) {
|
|
|
|
|
|
|
+ open func clearDiskCache(completion handler: (() -> Void)? = nil) {
|
|
|
ioQueue.async {
|
|
ioQueue.async {
|
|
|
do {
|
|
do {
|
|
|
try self.diskStorage.removeAll()
|
|
try self.diskStorage.removeAll()
|
|
@@ -607,6 +616,12 @@ open class ImageCache {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ /// Clears the expired images from memory & disk storage. This is an async operation.
|
|
|
|
|
+ open func cleanExpiredCache(completion handler: (() -> Void)? = nil) {
|
|
|
|
|
+ cleanExpiredMemoryCache()
|
|
|
|
|
+ cleanExpiredDiskCache(completion: handler)
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
/// Clears the expired images from disk storage. This is an async operation.
|
|
/// Clears the expired images from disk storage. This is an async operation.
|
|
|
open func cleanExpiredMemoryCache() {
|
|
open func cleanExpiredMemoryCache() {
|