Reading, writing and storing JSON with Node on Heroku

后端 未结 1 479
孤独总比滥情好
孤独总比滥情好 2021-02-05 10:49

I am building an App based on Node.js running on Heroku.

The app uses a JSON file which at the moment is being pushed with the rest of the app, and we are reading and wr

1条回答
  •  孤独总比滥情好
    2021-02-05 11:27

    Disclosure: I am the node.js platform owner at Heroku.

    You will need to bring the state out of your application. For replacing JSON files in a node app, you should look at mongo, s3, and redis:

    • mongo: feature-rich and reasonably fast
    • s3: abstraction that maps best to 'filesystem' storage (take care with permissions)
    • redis: simple and fast

    Personally, I prefer redis for simple use cases (it sounds like yours might qualify). You can just dump JSON in and parse it out. Alternatively, the most popular redis client for node provides a friendly interface for simple hashes:

    https://github.com/mranney/node_redis#friendlier-hash-commands

    Redis, mongo, s3:

    • https://elements.heroku.com/search?q=redis
    • https://elements.heroku.com/search?q=mongo
    • https://devcenter.heroku.com/articles/s3

    0 讨论(0)
提交回复
热议问题