Move set locks and refresh flag to base cache implementation.

This will allow us to better handle race conditions and cache invalidation.
Handle set race conditions and refresh handling in all caches.