When enabling/disabling query cache, make sure we are connected first

I'm using Octopus in an environment where we do a fair amount of forking and connect/disconnect calls, and (I think) because of this I somehow ran afoul of the assumption in enable_query_cache! that `v.connection` would always succeed. However, in `selection_connection` you had already noted that Rails 3.1/3.2 set `automatic_reconnect` to false when a connection pool is closed, so I generalized that safety mechanism and applied it to `eanble_query_cache!` and `disable_query_cache!`.

Oh, and FWIW, specs pass locally for me. Dunno about what they will look like on travis, yet.