Hacker News new | ask | show | jobs
by code_duck 5471 days ago
The way I've stored things in flat files is to make use of the file system's lookup capabilities. I wouldn't suggest storing data that may be requested or written to by more than one client at once with a method such as this, either. I wouldn't try to use it like a C array or anything. One file per user or more makes sense. I've also used stuff like this for system admin scripts.

Something like

   user_id=int(request.GET['id'])
   data_type=int(request.GET['id'])
   json_file="{0}-{1}-chart_data.json".format(user_id,data_type)
   #get the file, decode, etc.
It's a quick and dirty caching method that has good persistence, of course, is relatively performant under low loads and easy to understand.

Thanks, I'll check out the MySQL thing, but I'm not actually intending to build my own database.