Authored by Tracy Harton

enable FMDB statement Cache, flush on didReceiveMemoryWarning

... ... @@ -164,11 +164,18 @@
-(void)didReceiveMemoryWarning
{
@synchronized(self)
{
[dao didReceiveMemoryWarning];
}
}
-(void) removeAllCachedImages
{
[dao removeAllCachedImages];
@synchronized(self)
{
[dao removeAllCachedImages];
}
}
@end
... ...
... ... @@ -42,5 +42,6 @@
-(void) addData: (NSData*) data LastUsed: (NSDate*)date ForTile: (uint64_t) tileHash;
-(void) purgeTiles: (NSUInteger) count;
-(void) removeAllCachedImages;
-(void)didReceiveMemoryWarning;
@end
... ...
... ... @@ -35,9 +35,8 @@
-(void)configureDBForFirstUse
{
// [db executeUpdate:@"DROP TABLE ZCACHE"];
[db executeUpdate:@"CREATE TABLE IF NOT EXISTS ZCACHE (ztileHash INTEGER PRIMARY KEY, zlastUsed DOUBLE, zdata BLOB)"];
[db executeUpdate:@"CREATE INDEX zlastUsedIndex ON ZCACHE(zLastUsed)"];
[db executeUpdate:@"CREATE INDEX IF NOT EXISTS zlastUsedIndex ON ZCACHE(zLastUsed)"];
}
-(id) initWithDatabase: (NSString*)path
... ... @@ -55,6 +54,7 @@
}
[db setCrashOnErrors:TRUE];
[db setShouldCacheStatements:TRUE];
[self configureDBForFirstUse];
... ... @@ -151,7 +151,11 @@
{
RMLog(@"Error occured adding data");
}
// RMLog(@"done\t%d", tileHash);
}
-(void)didReceiveMemoryWarning
{
[db clearCachedStatements];
}
@end
... ...