Tighten up statement cache handling a little

* Debug log what's going on.
* Each active connection was doing the same operation on the shared cache each time the AIS changed.
* Include #1207
* Invalidate the old statement cache itself as well as removing it, since idle connections may point to it.