0

I currently have an application built with Express.js that runs via Heroku. I need to define a global variable that I can decrement each time a specific function is called, but I'm not sure how to do that programatically. I have a file of constants called consts.js and was trying to just set the variable (REMAINING) as follows: CONST.REMAINING -= 1 whenever the function is called, but unfortunately that doesn't work. What is a better way to go about this?

user3802348
  • 2,502
  • 11
  • 36
  • 49

1 Answers1

1

There's a good explanation of Heroku’s ephemeral filesystem which is a good place to start. In a nutshell, do not use the /tmp to store any variables or application level data as it will get destroyed.

It is suggested to use Amazon S3 or a similar durable store. It may be overkill for a single variable but I would look at using Redis just because of its speed. You could also look at programmatic access of Heroku config vars as well.

Community
  • 1
  • 1
kripy
  • 91
  • 4