0

I'm curious about best practices here.

Currently, I save all the feature flags (https://en.wikipedia.org/wiki/Feature_toggle) in the database. When I have to show some feature, I read the status (True/False) from it and then show/hide it depending on the value. There are a ton of these feature flags in my application and I'm constantly pinging the database throughout application.

Is there a better way? Saving it in database, but loading in cache (memory?) and reading from it? Updating that cache when something changes?

edit: Turning on/off is happening on the server side. Server then sync those changes to the application which is then saving it to the database.

Also, some pros/cons and memory impact of these options would be nice. Didn't find anything similar on the web.

Beemo
  • 405
  • 5
  • 17
  • We can use Shared preferences to store the key-value/flags (Small set of data), especially in a case of flag /app setting data database is not recommended. – ranjan Mar 16 '17 at 15:45
  • Database is overkill- Shared prefferences should be better, but i have a question- Do you expect to be able remotelly to toggle feature, or each build have set those in advance – X3Btel Mar 16 '17 at 15:58
  • Edited question. – Beemo Mar 16 '17 at 16:13

1 Answers1

0

this and this . SQLite would be overkill as you need to store simple key/value pairs, and the value is primitive boolean. Also you wont need to query big amount of data, as far as I understand you would only check for s single key at a time. Android is automatically caching the SharedPreference so you wont need to bother with that. Unless there isnt complex structure of values there is no point in using SQLite

Community
  • 1
  • 1
X3Btel
  • 1,358
  • 12
  • 20