Replace 'has_key' with 'in'

There are several places (mostly to do with caches) where we use the old
has_key method. The idiomatic syntax for this is to use the 'in' operator.
Caches implement __contains__, so this works fine.

Testing done: Ran unit tests.