@@ -36,10 +36,8 @@ - (instancetype)initWithDelegate:(id<SPStorageObserver>)aDelegate
3636 if (self) {
3737 _delegate = aDelegate;
3838 _objects = [NSMutableDictionary dictionaryWithCapacity: 10 ];
39- _ghosts = [NSMutableDictionary dictionaryWithCapacity: 10 ];
4039 _allObjects = [NSMutableDictionary dictionaryWithCapacity: 10 ];
41- _objectList = [NSMutableArray arrayWithCapacity: 10 ];
42-
40+
4341 NSString *queueLabel = @" com.simperium.JSONstorage" ;
4442 _storageQueue = dispatch_queue_create ([queueLabel cStringUsingEncoding: NSUTF8StringEncoding], NULL );
4543 }
@@ -140,7 +138,7 @@ - (NSDictionary *)faultObjectsForKeys:(NSArray *)keys bucketName:(NSString *)buc
140138 // Batch fault a bunch of objects for efficiency
141139 // All objects are already in memory, for now at least...
142140 NSArray *objectsAsList = [self objectsForKeys: [NSSet setWithArray: keys] bucketName: bucketName];
143- NSMutableDictionary *objectDict = [NSMutableDictionary dictionaryWithCapacity: _objectList.count ];
141+ NSMutableDictionary *objectDict = [NSMutableDictionary dictionary ];
144142 for (id <SPDiffable>object in objectsAsList) {
145143 [objectDict setObject: object forKey: object.simperiumKey];
146144 }
@@ -210,22 +208,16 @@ - (void)deleteObject:(id)dict
210208}
211209
212210- (void )deleteAllObjectsForBucketName : (NSString *)bucketName {
213- // NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
214- // NSEntityDescription *entity = [NSEntityDescription entityForName:entityName inManagedObjectContext:context];
215- // [fetchRequest setEntity:entity];
216- //
217- // // No need to fault everything
218- // [fetchRequest setIncludesPropertyValues:NO];
219- //
220- // NSError *error;
221- // NSArray *items = [context executeFetchRequest:fetchRequest error:&error];
222- //
223- // for (NSManagedObject *managedObject in items) {
224- // [context deleteObject:managedObject];
225- // }
226- // if (![context save:&error]) {
227- // NSLog(@"Simperium error deleting %@ - error:%@",entityName,error);
228- // }
211+ dispatch_sync (self.storageQueue , ^{
212+ // Nuke Bucket Entities from the `allObjects` collection
213+ NSDictionary <NSString *, SPObject *> *bucket = [self .objects objectForKey: bucketName];
214+ for (NSString *key in bucket.allKeys ) {
215+ [self .allObjects removeObjectForKey: key];
216+ }
217+
218+ // And now nuke the entire bucket
219+ [self .objects removeObjectForKey: bucketName];
220+ });
229221}
230222
231223- (void )validateObjectsForBucketName : (NSString *)bucketName
0 commit comments