diff --git a/Sources/FoundationNetworking/URLCache.swift b/Sources/FoundationNetworking/URLCache.swift index e74805e049..0da13d8f3e 100644 --- a/Sources/FoundationNetworking/URLCache.swift +++ b/Sources/FoundationNetworking/URLCache.swift @@ -350,6 +350,18 @@ open class URLCache : NSObject { } } + /*! + @method initWithMemoryCapacity:diskCapacity:directoryURL: + @abstract Initializes an NSURLCache with the given capacity and directory. + @param memoryCapacity the capacity, measured in bytes, for the cache in memory. Or 0 to disable memory cache. + @param diskCapacity the capacity, measured in bytes, for the cache on disk. Or 0 to disable disk cache. + @param directoryURL the path to a directory on disk where the cache data is stored. Or nil for default directory. + @result an initialized NSURLCache, with the given capacity, optionally backed by disk. + */ + public convenience init(memoryCapacity: Int, diskCapacity: Int, directory: URL? = nil) { + self.init(memoryCapacity: memoryCapacity, diskCapacity: diskCapacity, diskPath: directory?.path) + } + private func identifier(for request: URLRequest) -> String? { guard let url = request.url else { return nil }