Yaroslav Pesotskii
Yaroslav Pesotskii

Reputation: 91

React-native in which database of saved cache

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

Upvotes: 1

Views: 825

Answers (2)

TheBritishAreComing
TheBritishAreComing

Reputation: 1727

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"

Upvotes: 1

Newbie
Newbie

Reputation: 4829

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.

Upvotes: 1

Related Questions