Make Cache system more flexible

This changes the Cache class, so that it's just a proxy for multiple possible backends.
It also adds support for caching via apc.