Authored by Vladimir Vyskocil

Fix for Issue 96 : need API to clear map tile cache

... ... @@ -111,7 +111,6 @@
-(void) didReceiveMemoryWarning
{
LogMethod();
}
-(NSString *)uniqueTilecacheKey
... ... @@ -136,5 +135,8 @@
return [self shortAttribution];
}
-(void) purgeAllTiles
{
}
@end
... ...
... ... @@ -105,7 +105,6 @@
- (void) didReceiveMemoryWarning
{
LogMethod();
[cache didReceiveMemoryWarning];
}
... ... @@ -146,4 +145,9 @@
return [tileSource tilePath];
}
-(void) purgeAllTiles
{
[cache purgeAllTiles];
}
@end
... ...
... ... @@ -163,7 +163,6 @@
-(void)didReceiveMemoryWarning
{
LogMethod();
if (self.databasePath==nil) {
RMLog(@"unknown db path, unable to reinitialize dao!");
return;
... ... @@ -176,4 +175,9 @@
}
-(void) purgeAllTiles
{
[dao purgeAllTiles];
}
@end
... ...
... ... @@ -66,7 +66,6 @@
-(void) didReceiveMemoryWarning
{
LogMethod();
[cache removeAllObjects];
}
... ... @@ -128,4 +127,9 @@
[cache setObject:image forKey:key];
}
-(void) purgeAllTiles
{
[cache removeAllObjects];
}
@end
... ...
... ... @@ -39,13 +39,14 @@ typedef enum {
@protocol RMTileCache<NSObject>
/// Returns the cached image if it exists. nil otherwise.
// Returns the cached image if it exists. nil otherwise.
-(RMTileImage*) cachedImage:(RMTile)tile;
-(void)didReceiveMemoryWarning;
@optional
-(void)addTile: (RMTile)tile WithImage: (RMTileImage*)image;
-(void)purgeAllTiles;
@end
... ... @@ -59,12 +60,13 @@ typedef enum {
+(NSNumber*) tileHash: (RMTile)tile;
/// Add tile to cache
// Add tile to cache
-(void)addTile: (RMTile)tile WithImage: (RMTileImage*)image;
/// Add another cache to the chain
// Add another cache to the chain
-(void)addCache: (id<RMTileCache>)cache;
-(void)didReceiveMemoryWarning;
@end
... ...
... ... @@ -133,13 +133,19 @@
-(void)didReceiveMemoryWarning
{
LogMethod();
for (id<RMTileCache> cache in caches)
{
[cache didReceiveMemoryWarning];
}
}
-(void) purgeAllTiles
{
for (id<RMTileCache> cache in caches)
{
[cache purgeAllTiles];
}
}
@end
@implementation RMTileCache ( Configuration )
... ...
... ... @@ -40,6 +40,7 @@
-(void) touchTile: (uint64_t) tileHash withDate: (NSDate*) date;
-(void) addData: (NSData*) data LastUsed: (NSDate*)date ForTile: (uint64_t) tileHash;
-(void) purgeTiles: (NSUInteger) count;
-(void) purgeAllTiles;
//-(NSArray*) getLocalTimetableInformationAt: (int)stopId;
... ...
... ... @@ -122,6 +122,14 @@
}
-(void) purgeAllTiles
{
BOOL result = [db executeUpdate: @"DELETE FROM ZCACHE"];
if (result == NO) {
RMLog(@"Error purging all cache");
}
}
-(void) touchTile: (uint64_t) tileHash withDate: (NSDate*) date
{
BOOL result = [db executeUpdate: @"UPDATE ZCACHE SET zlastUsed = ? WHERE ztileHash = ? ",
... ...
... ... @@ -58,4 +58,6 @@
-(NSString *)shortAttribution;
-(NSString *)longAttribution;
-(void)purgeAllTiles;
@end
... ...