sourcedelica/unix-cb — pull request #15 by ggrossman (2014-12-05 06:27:46+00:00)
Title: Pluggable storage backends for cb_server, including file-based.

`STORAGE_ENGINE` environment variable can now be set to `dummy`, `file` or `redis`. Default is `file`.

- In `dummy` mode, user records are stored in memory and not persisted.
- In `file` mode, a .json file is written for each user into the `../lib/cb/recs` directory.
- In `redis` mode, user records are persisted in Redis.

Note: Reading and writing the same recs files that the C code uses poses some challenges, so currently, a `.json` file is being created alongside the old rec file. The C code assumes that only certain keys will be in the file, and will delete any other ones when it writes a record. We can fix this by having the C code talk to a Web service in node.js-land instead of reading/writing files directly.

Also: Moved most of the functions in `cb_server.js` to be inside the closure that accepts connections, so that `client` doesn't have to be passed around everywhere.