In the same vein, I have a single-file library which allows you to use flat files as key-value DBs. Uses SQLite under the hood. Sharing in case someone finds it useful: https://github.com/aaviator42/storx
Looking at the usage, I thought this syntax was interesting:
//here's how we read a key $sx->readKey('username', $username);
Is there a reason you are requiring a variable to be passed by reference to the readKey function, instead of doing:
$username = $sx->readKey('username');
EDIT: ahh, I see you have a returnKey('key') function that works that way