iOS: fix multi context,share same zone storage
This commit is contained in:
parent
33c681031d
commit
aee2ed6027
@ -34,6 +34,7 @@
|
||||
@property(nonatomic, strong) DoricJSLoaderManager *jsLoaderManager;
|
||||
@property(nonatomic, strong) DoricNativeDriver *nativeDriver;
|
||||
@property(nonatomic, strong) DoricContextManager *contextManager;
|
||||
@property(nonatomic, strong) NSMapTable<NSString *, id> *storageCaches;
|
||||
|
||||
+ (instancetype)instance;
|
||||
|
||||
|
@ -34,6 +34,9 @@ - (instancetype)init {
|
||||
_enableRecordSnapshot = NO;
|
||||
_jsLoaderManager = [DoricJSLoaderManager new];
|
||||
_contextManager = [DoricContextManager new];
|
||||
_storageCaches = [[NSMapTable alloc] initWithKeyOptions:NSPointerFunctionsCopyIn
|
||||
valueOptions:NSPointerFunctionsWeakMemory
|
||||
capacity:0];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
#import "DoricStoragePlugin.h"
|
||||
#import "DoricExtensions.h"
|
||||
#import "DoricSingleton.h"
|
||||
|
||||
#if __has_include(<PINCache/PINCache.h>)
|
||||
|
||||
@ -184,8 +185,12 @@ - (DoricCache *)getDiskCache:(NSString *)zone {
|
||||
if (zone) {
|
||||
diskCache = self.cachedMap[zone];
|
||||
if (!diskCache) {
|
||||
diskCache = [[DoricCache alloc] initWithName:[NSString stringWithFormat:@"%@_%@", doric_prefix, zone]
|
||||
rootPath:self.basePath];
|
||||
diskCache = [DoricSingleton.instance.storageCaches objectForKey:zone];
|
||||
if (!diskCache) {
|
||||
diskCache = [[DoricCache alloc] initWithName:[NSString stringWithFormat:@"%@_%@", doric_prefix, zone]
|
||||
rootPath:self.basePath];
|
||||
[DoricSingleton.instance.storageCaches setObject:diskCache forKey:zone];
|
||||
}
|
||||
self.cachedMap[zone] = diskCache;
|
||||
}
|
||||
} else {
|
||||
|
Reference in New Issue
Block a user