Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Only if you’re ok with an empty page after server restart.


If it'a controlled restart, you can dump your memory onto a file when shutting down, then reload the dump when you restart. If it's a crash, yes, you will lose everything. Or you can do Append Only File persistence like Redis, in which case you won't lose anything in each case.


> dump your memory onto a file when shutting down, then reload the dump when you restart

To me this sounds like building your own db but worse.


Agree for the dump idea, but AOF persistence is quite easy to do (literally open a file and append).

Of course you'll have to choose the right data structures in memory, but that can be ad hoc to your app, so considerably less complex than a general purpose database.

The only problem is when you go out of memory, but if you have an eviction strategy (i.e. a 24 hours life per post), you don't need to scale for a long time.


We’d still need code to load the data back, also to continously test that code (or debug in production), plus handle data migrations. There might be more use cases. Using a regular db might be simpler at this point, depending on the project’s setup.


Loading the data back is just reading the log file and applying every record one after the other (ignoring records outside the time horizon). Sure you will need to maintain the code, but it's not as complex as writing a database from scratch, as you suggested.




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: