FMDatabasePool Class Reference
| Inherits from | NSObject |
| Declared in | FMDatabasePool.h FMDatabasePool.m |
Overview
Pool of FMDatabase objects.
See also
Warning: Before using FMDatabasePool, please consider using FMDatabaseQueue instead.
If you really really really know what you’re doing and FMDatabasePool is what
you really really need (ie, you’re using a read only database), OK you can use
it. But just be careful not to deadlock!
For an example on deadlocking, search for:
ONLY_USE_THE_POOL_IF_YOU_ARE_DOING_READS_OTHERWISE_YOULL_DEADLOCK_USE_FMDATABASEQUEUE_INSTEAD
in the main.m file.
Tasks
Initialization
-
+ databasePoolWithPath:Create pool using path.
-
– initWithPath:Create pool using path.
Keeping track of checked in/out databases
-
– countOfCheckedInDatabasesNumber of checked-in databases in pool
-
– countOfCheckedOutDatabasesNumber of checked-out databases in pool
-
– countOfOpenDatabasesTotal number of databases in pool
-
– releaseAllDatabasesRelease all databases in pool
Perform database operations in pool
-
– inDatabase:Synchronously perform database operations in pool.
-
– inTransaction:Synchronously perform database operations in pool using transaction.
-
– inDeferredTransaction:Synchronously perform database operations in pool using deferred transaction.
-
– inSavePoint:Synchronously perform database operations in pool using save point.
Instance Methods
countOfCheckedInDatabases
Number of checked-in databases in pool
- (NSUInteger)countOfCheckedInDatabasesReturn Value
Number of databases
Declared In
FMDatabasePool.hcountOfCheckedOutDatabases
Number of checked-out databases in pool
- (NSUInteger)countOfCheckedOutDatabasesReturn Value
Number of databases
Declared In
FMDatabasePool.hcountOfOpenDatabases
Total number of databases in pool
- (NSUInteger)countOfOpenDatabasesReturn Value
Number of databases
Declared In
FMDatabasePool.hinDatabase:
Synchronously perform database operations in pool.
- (void)inDatabase:(void ( ^ ) ( FMDatabase *db ))blockParameters
- block
The code to be run on the
FMDatabasePoolpool.
Declared In
FMDatabasePool.hinDeferredTransaction:
Synchronously perform database operations in pool using deferred transaction.
- (void)inDeferredTransaction:(void ( ^ ) ( FMDatabase *db , BOOL *rollback ))blockParameters
- block
The code to be run on the
FMDatabasePoolpool.
Declared In
FMDatabasePool.hinSavePoint:
Synchronously perform database operations in pool using save point.
- (NSError *)inSavePoint:(void ( ^ ) ( FMDatabase *db , BOOL *rollback ))blockParameters
- block
The code to be run on the
FMDatabasePoolpool.
Discussion
Warning: You can not nest these, since calling it will pull another database out of the pool and you’ll get a deadlock. If you need to nest, use [FMDatabase startSavePointWithName:error:] instead.
Declared In
FMDatabasePool.hinTransaction:
Synchronously perform database operations in pool using transaction.
- (void)inTransaction:(void ( ^ ) ( FMDatabase *db , BOOL *rollback ))blockParameters
- block
The code to be run on the
FMDatabasePoolpool.
Declared In
FMDatabasePool.h