huynguyencong / DataCache

Simple disk and memory cache for iOS
MIT License
101 stars 20 forks source link

How can i clean the caches when application exit ? #11

Closed alkincakiralar1996 closed 6 years ago

alkincakiralar1996 commented 7 years ago

i tried this but it didnt work

func applicationWillTerminate(_ application: UIApplication) {
 DataCache.instance.cleanAll()
}

not just cleanAll method

i tried with all clean method but it didn't work

huynguyencong commented 6 years ago

I just updated new version, try it again then let me know result. Thank you!

alii805 commented 6 years ago

which one is updated version. I have the issue to clean the cache. I am curious if the is completion block for cache expire that automatically called so I should be able to know that it is a time to go for server to fetch the fresh one.

huynguyencong commented 6 years ago

When you get data from DataCache, if it return nil, then get it from network.

alii805 commented 6 years ago

When I set this DataCache.instance.maxCachePeriodInSecond = 30 It should expire the data in 30 seconds but it never expire and Cache still return me the data. More over the handler which is DataCache.instance.cleanExpiredDiskCache(completion: {[weak self] in DataCache.instance.cleanAll() }) immediately called and clean the data. I thought it will called when data cache expired. Please help me

huynguyencong commented 6 years ago

Data cache will check whether it is expired when app is restarted