From 4b693e26e495d2311374dd61e56419628dff6331 Mon Sep 17 00:00:00 2001 From: Alex Li Date: Thu, 14 Jul 2022 17:28:47 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20[iOS]=20Improve=20cache=20?= =?UTF-8?q?container=20mutations=20(#803)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 1 + ios/Classes/core/PMCacheContainer.m | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 29275bba..7d17dfd5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ that can be found in the LICENSE file. --> ### Improvements - Improve `MD5Utils` on iOS. (#802) +- Improve cache container mutations on iOS. (#803) ### Fixes diff --git a/ios/Classes/core/PMCacheContainer.m b/ios/Classes/core/PMCacheContainer.m index d33ff697..1d9d413c 100644 --- a/ios/Classes/core/PMCacheContainer.m +++ b/ios/Classes/core/PMCacheContainer.m @@ -16,7 +16,9 @@ - (instancetype)init { } - (void)putAssetEntity:(PMAssetEntity *)entity { - map[entity.id] = entity; + @synchronized (map) { + self->map[entity.id] = entity; + } } - (PMAssetEntity *)getAssetEntity:(NSString *)id { @@ -24,7 +26,9 @@ - (PMAssetEntity *)getAssetEntity:(NSString *)id { } - (void)clearCache { - [map removeAllObjects]; + @synchronized (map) { + [self->map removeAllObjects]; + } } @end