-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support unlimited disk cache time #566
Conversation
Current coverage is 73.63% (diff: 100%)@@ master #566 diff @@
==========================================
Files 21 21
Lines 2240 2242 +2
Methods 0 0
Messages 0 0
Branches 0 0
==========================================
- Hits 1654 1651 -3
- Misses 586 591 +5
Partials 0 0
|
@@ -93,6 +93,7 @@ open class ImageCache { | |||
|
|||
/// The longest time duration in second of the cache being stored in disk. | |||
/// Default is 1 week (60 * 60 * 24 * 7 seconds). | |||
/// Setting this to a negative value will make the disk cache never expiring. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
setting this to 0 should have the same effect as negative
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's intended to have only negative number for "forever". 0 means expiring immediately. And since there is a default non-zero value here, it is better to opt out 0 so we could avoid to introduce misunderstanding.
@@ -475,7 +476,7 @@ open class ImageCache { | |||
|
|||
let diskCacheURL = URL(fileURLWithPath: diskCachePath) | |||
let resourceKeys: Set<URLResourceKey> = [.isDirectoryKey, .contentAccessDateKey, .totalFileAllocatedSizeKey] | |||
let expiredDate = Date(timeIntervalSinceNow: -maxCachePeriodInSecond) | |||
let expiredDate = (maxCachePeriodInSecond < 0) ? nil : Date(timeIntervalSinceNow: -maxCachePeriodInSecond) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<= 0
Support unlimited disk cache time
For #559