1

I am building a simple Web App for which I want to store 3 variables, which should be available to every user and be stored dynamically.

Specifically I am using Flask. In the past I simply stored the data in text files or pickled them. Although this worked, this seems like an ugly solution and could at least theoretically lead to race condition problems when used by multiple persons.

The better approach would probably be to use a database, but this seems like a bit of an overkill when really the only thing it would store was a single entry in a single table.

Is there a good practice for this kind of task? Unfortunately I haven't found any appropriate solutions for this task, as the problem doesn't seem very common.

stekepego
  • 35
  • 1
  • 5
  • It seems that you need to add some constant values. Read https://stackoverflow.com/questions/2682745/how-do-i-create-a-constant-in-python – Panos Angelopoulos Apr 20 '18 at 11:14
  • Ok, seems like I misunderstood and misused the term persistent. Updated the question. – stekepego Apr 20 '18 at 11:17
  • Consider using [Redis](https://redis.io/). In general6 it's a key-value in-memory storage. This will also enable you to scale horizontally as it's easy to run as a service and access from multiple servers. – Seer.The Apr 20 '18 at 11:27
  • Ok, Redis seems like a really nice option for my task(s). Thanks, if you would like to post it as an answer, I would accept it. – stekepego Apr 20 '18 at 13:31

0 Answers0