Skip to content

Commit

Permalink
Limit Queue size to 1000 (#565)
Browse files Browse the repository at this point in the history
  • Loading branch information
f2prateek authored Jun 27, 2016
1 parent 1ef66d9 commit e18ef89
Showing 1 changed file with 4 additions and 14 deletions.
18 changes: 4 additions & 14 deletions Analytics/Classes/Internal/SEGSegmentIntegration.m
Original file line number Diff line number Diff line change
Expand Up @@ -416,23 +416,13 @@ - (void)enqueueAction:(NSString *)action dictionary:(NSMutableDictionary *)paylo
- (void)queuePayload:(NSDictionary *)payload
{
@try {
if (self.queue.count > 1000) {
// Remove the oldest element.
[self.queue removeObjectAtIndex:0];
}
[self.queue addObject:payload];
[[self.queue copy] writeToURL:[self queueURL] atomically:YES];
[self flushQueueByLength];

}
@catch (NSException *exception) {
SEGLog(@"%@ Error writing payload: %@", self, exception);
}
}

- (void)queuePayloadFromArray:(NSArray *)payloadArray
{
@try {
[self.queue addObjectsFromArray:payloadArray];
[[self.queue copy] writeToURL:[self queueURL] atomically:YES];
[self flushQueueByLength];

}
@catch (NSException *exception) {
SEGLog(@"%@ Error writing payload: %@", self, exception);
Expand Down

0 comments on commit e18ef89

Please sign in to comment.