Recommended way to store values persistently

I need a way to store values persistently. The use case is storing data from a webserver, so concurrency support is necessary. I need to store an arbitrary number of strings/integers. Each string isn’t very long, although it’s not a fixed size. I guess what I need exactly would be some kind of set which is backed in file storage.

When the webserver was implemented in Node, I was using an in memory Object which I would write to disk on each update, which seemed like a bad idea at the time, but it was simple to implement. Since I’m redoing the server in Go, I was wondering what the best way to store such data is. I could implement the same thing with Go, but I am not sure that this is the best way. Would a key-value store library like Bolt be useful for this scenario? Or is using a storage backed map[string]bool fine?

Thanks for the help.

Based on the fact that you were using a single file before, am I correct in assuming that you only intend to have 1 web server running at any time? Eg we won’t have 4 servers, all running on different machines, reading and writing from the same set of strings?

If so, something simple like Bolt or SQLite would be fine, and is likely way less error prone than using a text file. My guess is the work to make this work with either of those would be fairly minimal and would save you some headaches compared to a disk-backed map/json file.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.