Last active
September 3, 2019 04:48
-
-
Save mjhassan/41404ee8d96e5c4aaac9993c0959cc4d to your computer and use it in GitHub Desktop.
Shared url cache configuration
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| extension URLCache { | |
| static func configSharedCache(directory: String? = Bundle.main.bundleIdentifier, memory: Int = 0, disk: Int = 0) { | |
| URLCache.shared = { | |
| let cacheDirectory = (NSSearchPathForDirectoriesInDomains(.cachesDirectory, .userDomainMask, true)[0] as String).appendingFormat("/\(directory ?? "cache")/" ) | |
| return URLCache(memoryCapacity: memory, diskCapacity: disk, diskPath: cacheDirectory) | |
| }() | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment