Add cache generator function

Hi Ricardo,

I added a very useful function to the cache which allows easy async cache generation. Would be great if you could merge the change.

Thanks a lot.