mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-28 20:25:33 +08:00
Implement efficient DiskCache.clear()
Summary: public Ability to efficiently remove all keys with a particular prefix Reviewed By: tadeuzagallo Differential Revision: D2658741 fb-gh-sync-id: 3770f061c83288efe645162ae84a9fd9194d2fd6
This commit is contained in:
committed by
facebook-github-bot-3
parent
aaffb239ca
commit
fc5a8678d3
@@ -435,6 +435,24 @@ RCT_EXPORT_METHOD(clear:(RCTResponseSenderBlock)callback)
|
||||
callback(@[RCTNullIfNil(error)]);
|
||||
}
|
||||
|
||||
RCT_EXPORT_METHOD(clearPrefix:(NSString *)prefix callack:(RCTResponseSenderBlock)callback)
|
||||
{
|
||||
NSDictionary *errorOut = [self _ensureSetup];
|
||||
if (errorOut) {
|
||||
callback(@[errorOut]);
|
||||
return;
|
||||
}
|
||||
|
||||
NSMutableArray<NSString *> *keys = [NSMutableArray array];
|
||||
for (NSString *key in _manifest.allKeys) {
|
||||
if ([key hasPrefix:prefix]) {
|
||||
[keys addObject:key];
|
||||
}
|
||||
}
|
||||
|
||||
[self multiRemove:keys callback:callback];
|
||||
}
|
||||
|
||||
RCT_EXPORT_METHOD(getAllKeys:(RCTResponseSenderBlock)callback)
|
||||
{
|
||||
NSDictionary *errorOut = [self _ensureSetup];
|
||||
|
||||
Reference in New Issue
Block a user