filipw/AspNetWebApi-OutputCache — pull request #40 by vegardlarsen (2013-09-27 16:01:49+00:00)
Title: Allow using custom cache keys.

This is a suggested implementation for issue #39.

The idea is to use the dependency scope to get the `ICacheKeyGenerator` that is requested. So if you have a `UserSpecificCacheKeyGenerator` that you want to use with a specific route:

- register the `UserSpecificCacheKeyGenerator` with your DI injector. For Autofac, this would be `builder.RegisterInstance(new UserSpecificCacheKeyGenerator);` or similar
- decorate with `[CacheOutput(CacheKeyGenerator = typeof(UserSpecificCacheKeyGenerator))]`

If you want to change the default cache key generator, again using Autofac: `builder.RegisterInstance(new SuperNiceCacheKeyGenerator()).As();` or similar. The key part is to register it as `ICacheKeyGenerator`, which is used by default. If no generator is registered in your DI, the DefaultCacheKeyGenerator is used.

Future ideas: maybe allow classes with parameterless constructors to be constructed used `Activator.CreateInstance`.