Moves the VersionBits* functions to be methods of the cache class,
and makes the cache and its lock private to the class.
This is a partial backport of core#19438
https://github.com/bitcoin/bitcoin/pull/19438/commits/0cfd6c6a8f929d5567ac41f95c21548f115efee5
Depends on D12224