开发者

Using the global object as storage

开发者 https://www.devze.com 2023-03-28 20:11 出处:网络
I have made an application that is receiving location data from a few web clients on regular intervals. I made a quick implementation using couchdb, but as couchdb creates a new revision for each upda

I have made an application that is receiving location data from a few web clients on regular intervals. I made a quick implementation using couchdb, but as couchdb creates a new revision for each update and the data is quite frequently updated, it consumed a lot of disk space whereas the historic data was of little significance. I looked into M开发者_JS百科ongoDB instead, but as I was thinking how I could make the MongoDB implementation, I had another idea:

The global object is in the process scope, so it can be used to share data between sessions. Persistence beyond session is not required, so I dropped the database completely and stored all the data in the global object (and persisted some data for user convenience in the HTML5 localStorage using javascript). The complexity of the backend was greatly reduced, and the solution felt somewhat elegant, but I still feel like I need to take a shower...

So to my question: Are there any obvious pitfalls with this solution that I haven't thought about?


Congrats you have rediscovered memcache. (I did it twice) If you need to store this data then you actually should to save it to db, because server app restart will erase all data from RAM. So actually is better to use memcache and asynchronous writing to db.

0

精彩评论

暂无评论...
验证码 换一张
取 消