Added cache decorator.

https://gist.github.com/przemekmazurek/5590467eaf5f4417b087
You can implement the second condition (after 'or') as a inner function. This way a "complicated" condition can be invoked as a named function and becomes clearer.