hyperoslo / Cache

:package: Nothing but Cache.
Other
2.96k stars 335 forks source link

remove older files not recent #304

Closed boduoduo closed 1 week ago

3lvis commented 2 years ago

Wait, are you telling me this code was wrong all this time and no one noticed? :O

boduoduo commented 2 years ago

I viewed the apple developer document,timeIntervalSinceReferenceDate returns the interval between the date object and 00:00:00 UTC on 1 January 2001, so if using time1 > time2, the recent files will be in the front of the files sorted, and they will be removed in advance.

dfmuir commented 3 weeks ago

I came here to open this exact pull request. Right now when calling removeExpiredObjects with cache size above its maxSize the most recently cached files are deleted. It seems clear that the oldest objects should be removed instead.

I would love to avoid forking this repo. @3lvis please consider merging this important bugfix.

3lvis commented 1 week ago

Merged @dfmuir !