setProvider

Sets the provider function and clears the cache. Passing the same provider again is a no-op, so callers should keep a stable reference.