diff --git a/SignalServiceKit/src/Storage/OWSPrimaryStorage.m b/SignalServiceKit/src/Storage/OWSPrimaryStorage.m index 8afb8cf7b..1b04aedd3 100644 --- a/SignalServiceKit/src/Storage/OWSPrimaryStorage.m +++ b/SignalServiceKit/src/Storage/OWSPrimaryStorage.m @@ -52,6 +52,7 @@ void VerifyRegistrationsForPrimaryStorage(OWSStorage *storage) @property (atomic) BOOL areAsyncRegistrationsComplete; @property (atomic) BOOL areSyncRegistrationsComplete; +@property (nonatomic, readonly) YapDatabaseConnectionPool *dbReadPool; @end @@ -75,10 +76,10 @@ void VerifyRegistrationsForPrimaryStorage(OWSStorage *storage) if (self) { [self loadDatabase]; - _dbReadConnection = [self newDatabaseConnection]; + _dbReadPool = [[YapDatabaseConnectionPool alloc] initWithDatabase:self.database]; _dbReadWriteConnection = [self newDatabaseConnection]; _uiDatabaseConnection = [self newDatabaseConnection]; - + // Increase object cache limit. Default is 250. _uiDatabaseConnection.objectCacheLimit = 500; [_uiDatabaseConnection beginLongLivedReadTransaction]; @@ -156,7 +157,8 @@ void VerifyRegistrationsForPrimaryStorage(OWSStorage *storage) - (void)resetStorage { - _dbReadConnection = nil; + _dbReadPool = nil; + _uiDatabaseConnection = nil; _dbReadWriteConnection = nil; [super resetStorage]; @@ -426,6 +428,11 @@ void VerifyRegistrationsForPrimaryStorage(OWSStorage *storage) return OWSPrimaryStorage.sharedManager.dbReadConnection; } +- (YapDatabaseConnection *)dbReadConnection +{ + return self.dbReadPool.connection; +} + + (YapDatabaseConnection *)dbReadWriteConnection { return OWSPrimaryStorage.sharedManager.dbReadWriteConnection;