The other day I was interviewing and I was asked the question "In which database is the cache stored on a mobile device?" I didn't even know what to say. How would you answer this question? P.S. I answered AsyncStorage, he ask which database he uses
CodePudding user response:
It depends, if by database they meant a SQL database
then sqlite. Other databases are available too Realm, PouchDb, Watermelon DB, Vasern, Firebase (as local database).
For simple key-value storage, there is the AsyncStorage (deprecated but replaced by similar community packages). Other solutions exist but are specific to other frameworks (for example Expo SecureStorage).
I would have proceded to investigate what are the Interviewer requirements to understand which of the listed solutions suits better the problem.
CodePudding user response:
This is a tricky one because it's going to rely heavily on context and if you've implemented an actual cache or it's just localStorage.
I would answer something like:
"When storing cache data on the device I would use AsyncStorage
which will use the native storage mechanism (SharedPreferences / UserDefaults) however this isn't secure and if I needed to secure data on the device I would look towards a third party library that implements Keychain storage"