简体   繁体   中英

How do I keep and update a persistent variable in a sinatra app on heroku

I have a very small sinatra app. it basically redirects to google search. I deployed it on heroku.I wanted to track the amounts of hits it got, so I added a "hits" variable and had it update every time the page was loaded. The problem I am facing is that every time I push a new release, the app reboots and the variable resets (which is not surprising, really).

Is there a way to keep a variable persistently? and update it as required? Can the heroku env_vars do that?

I was thinking about a local file store as a solution but that file would also be over written every time a new change is pushed. Do you guys have any idea how to fix that?

Well, there is no way to use heroku ENV vars for this. To do this, I created a simple database tab;e that keeps track of all the information.

如果您仅为此目的而使用数据库,则可能需要考虑仅以CSV格式写入文本文件,甚至使用内置的ruby logger方法

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM