database: Improve DatabaseMysql::masterPosWait() performance by caching the position

* This is useful for things like loads of refreshLinks jobs that call wfGetLB()->waitFor().

Change-Id: I05a564a3b73999517fec2476ed946e092c16c3d4