Ruby: To create a string cache that is faster: Array or SQL?

I am making a ruby ​​server with a cache of information about online clients. This information should be retained when the server shuts down. I can save it in a simple array and save it using Marshal, or I can use an SQL database (possibly MySQL). Which is better to use? I think the Array method is simple, but SQL is faster than? Thank!

+3
source share
2 answers

In fact, I would expect a serialized array to be significantly faster, since no indexing or extra row distribution is required. I think it all depends on whether you want to be able to fulfill requests for this information. If not, you do not need a database, you just need perseverance. You can also write the cache to a file.

+3
source

It depends on scalability requirements. If you expect thousands of records, you should use SQL or another database, although this does impose developer overhead. However, if you are dealing with a small number, you can get by simply serializing the objects and saving them to disk.

+4
source

Source: https://habr.com/ru/post/1776458/


All Articles