From db1015a6f003012572c3f325dc20371b00daa181 Mon Sep 17 00:00:00 2001 From: masakih Date: Wed, 17 Jun 2015 21:10:17 +0900 Subject: [PATCH] =?utf8?q?=E3=82=AD=E3=83=A3=E3=83=83=E3=82=B7=E3=83=A5?= =?utf8?q?=E3=83=95=E3=82=A1=E3=82=A4=E3=83=AB=E3=83=8F=E3=82=9A=E3=82=B9?= =?utf8?q?=E3=82=92=E3=83=8F=E3=82=99=E3=83=B3=E3=83=88=E3=82=99=E3=83=ABI?= =?utf8?q?D=E3=81=8B=E3=82=89=E7=94=9F=E6=88=90=E3=81=99=E3=82=8B=E3=82=88?= =?utf8?q?=E3=81=86=E3=81=AB=E3=81=97=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit キャッシュメモリサイズを128MBに変更 --- KCD/CustomHTTPProtocol.m | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/KCD/CustomHTTPProtocol.m b/KCD/CustomHTTPProtocol.m index 60abbed4..5f6d4e33 100644 --- a/KCD/CustomHTTPProtocol.m +++ b/KCD/CustomHTTPProtocol.m @@ -87,13 +87,17 @@ typedef void (^ChallengeCompletionHandler)(NSURLSessionAuthChallengeDisposition static id sDelegate; -+ (NSURL *)applicationSupportDirectory ++ (NSURL *)cacheFileURL { NSFileManager *fileManager = [NSFileManager defaultManager]; - return [[fileManager URLsForDirectory:NSApplicationSupportDirectory inDomains:NSUserDomainMask] lastObject]; + NSURL *path = [[fileManager URLsForDirectory:NSApplicationSupportDirectory inDomains:NSUserDomainMask] lastObject]; + NSBundle *mainBundle = [NSBundle mainBundle]; + NSString *bundleIdentifier = mainBundle.bundleIdentifier; + path = [path URLByAppendingPathComponent:bundleIdentifier]; + path = [path URLByAppendingPathComponent:@"cache.db"]; + return path; } - + (void)load { [NSURLProtocol registerClass:self]; @@ -134,10 +138,8 @@ static id sDelegate; // otherwise you don't see redirects . config.protocolClasses = @[ self ]; - NSURL *path = [self applicationSupportDirectory]; - path = [path URLByAppendingPathComponent:@"com.masakih.KCD"]; - path = [path URLByAppendingPathComponent:@"cache.db"]; - NSURLCache *cache = [[NSURLCache alloc] initWithMemoryCapacity:1024 * 1024 * 512 + NSURL *path = [self cacheFileURL]; + NSURLCache *cache = [[NSURLCache alloc] initWithMemoryCapacity:128 * 1024 * 1024 diskCapacity:1024 * 1024 * 1024 diskPath:path.path]; config.URLCache = cache; -- 2.11.0