0

I am using NSCache to deal with cache in my app. Can anybody explain to me how totalCostLimit and countLimit works.

I want to allow user input how may memory of using cache he wont to allow for our app and I understand that I need to use totalCostLimit and countLimit, but what happen to inputed data if user will close the app, will it be stored or cached somewhere by the app or I need to sore it in database and every time when user will open the app take that data and send it to totalCostLimit and countLimit.

Also I do not understand how to observe how much cache is weighting, I want to add that info to app so user whenever he wont will see hove much memory my app takes for cache in that specific moment.

Thank you for the answers!

  • To answer your first question regarding whether or not data stored in an NSCache instance will still be available after the user closes the app, the answer is no. Also, keep it mind that NSCache has an auto-eviction policy that can decide to remove items from the cache if memory is needed by other applications. For your question regarding "countLimit" and "totalCostLimit", the documentation does a nice job explaining these properties: https://developer.apple.com/documentation/foundation/nscache – Anas Merbouh Nov 03 '22 at 20:26

0 Answers0