trainingwheels/trainingwheels — pull request #68 by marktheunissen (2013-03-03 18:26:56+00:00)
Title: Caching system

Training Wheels is seriously slow when you have > +-10 users, and twice as bad as that when the connection is over SSH. To mitigate this, this branch implements a MongoDB object cache, similar to an ORM in some ways, but simpler.

The basic idea is that any object can extend CachedObject, and in it's constructor, provide an array of properties that must be saved when the object is cached (saving back to the cache happens in the destructor).

```php
$this->cachePropertiesAdd(array('exists', 'password', 'env_user_id'));
$this->cacheBuild($user_id);
```

This call to the parent class `cacheBuild` will fetch the id from Mongo, and populate any properties on the current object with data that it finds. For example, then we can create a `MySQLDatabaseResource` and call `->getPasswd()` on it, without it actually retrieving the password using the environment.

The logs were very useful in developing this, so check 'em out.

This pull request should be recreated with master as the target, rather than merging this particular one. The order of merges to master should be:

1. TW-95-ssh-conn
2. fix-bug-cloud9-res
3. better-loggin
4. **caching**