Database, Database Caching, Locking added

Database.inc not yet finished.