use connection pool for reads

pull/2/head
Michael Kirk
parent 2d86127324
commit 645a26cbdf

@ -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;

Loading…
Cancel
Save