Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
目前对于AccessToken、JsapiTicket和CardApiTicket在更新时的同步都是通过synchronized关键词来实现的,这样在进行集群时会有问题。
这个补丁修改了这些接口的同步机制,使用锁进行同步,并由WxMpConfigStorage提供锁的具体实现。在默认的WxMpInMemoryConfigStorage中直接使用了ReentrantLock来提供单服务器中多线程的同步。
对于需要集群的场景,可以通过缓存中间件来实现WxMpConfigStorage和Lock。以Redis为例,开发者只需提供Redis版的WxMpConfigStorage和Redis版本的锁实现即可。
企业号也存在类似的问题,因为暂时没有涉及企业号的开发,因此没有对企业号做相应的修改和测试。