Commit 6944ebb1 authored by 汪洋's avatar 汪洋

Merge branch 'yefengming/key为空修改' into 'master'

key为空加断言,return



See merge request !1
parents d5cc9001 45f61b01
...@@ -205,7 +205,6 @@ ...@@ -205,7 +205,6 @@
6003F587195388D20070C39A /* Frameworks */, 6003F587195388D20070C39A /* Frameworks */,
6003F588195388D20070C39A /* Resources */, 6003F588195388D20070C39A /* Resources */,
E6007FDDD71574B978C769A2 /* [CP] Embed Pods Frameworks */, E6007FDDD71574B978C769A2 /* [CP] Embed Pods Frameworks */,
E1CCA95CBE6C5EE39632CCC0 /* [CP] Copy Pods Resources */,
); );
buildRules = ( buildRules = (
); );
...@@ -224,8 +223,6 @@ ...@@ -224,8 +223,6 @@
6003F5AA195388D20070C39A /* Sources */, 6003F5AA195388D20070C39A /* Sources */,
6003F5AB195388D20070C39A /* Frameworks */, 6003F5AB195388D20070C39A /* Frameworks */,
6003F5AC195388D20070C39A /* Resources */, 6003F5AC195388D20070C39A /* Resources */,
BCD8154DD3F6B85FEF13F531 /* [CP] Embed Pods Frameworks */,
04CCA5F71C29A0973E2281CD /* [CP] Copy Pods Resources */,
); );
buildRules = ( buildRules = (
); );
...@@ -293,21 +290,6 @@ ...@@ -293,21 +290,6 @@
/* End PBXResourcesBuildPhase section */ /* End PBXResourcesBuildPhase section */
/* Begin PBXShellScriptBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */
04CCA5F71C29A0973E2281CD /* [CP] Copy Pods Resources */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "[CP] Copy Pods Resources";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-GMCache_Tests/Pods-GMCache_Tests-resources.sh\"\n";
showEnvVarsInLog = 0;
};
6C9F2FE77B3354A4C51B5AD9 /* [CP] Check Pods Manifest.lock */ = { 6C9F2FE77B3354A4C51B5AD9 /* [CP] Check Pods Manifest.lock */ = {
isa = PBXShellScriptBuildPhase; isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647; buildActionMask = 2147483647;
...@@ -326,21 +308,6 @@ ...@@ -326,21 +308,6 @@
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
showEnvVarsInLog = 0; showEnvVarsInLog = 0;
}; };
BCD8154DD3F6B85FEF13F531 /* [CP] Embed Pods Frameworks */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "[CP] Embed Pods Frameworks";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-GMCache_Tests/Pods-GMCache_Tests-frameworks.sh\"\n";
showEnvVarsInLog = 0;
};
C598F3B34142991DE4A43F45 /* [CP] Check Pods Manifest.lock */ = { C598F3B34142991DE4A43F45 /* [CP] Check Pods Manifest.lock */ = {
isa = PBXShellScriptBuildPhase; isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647; buildActionMask = 2147483647;
...@@ -359,21 +326,6 @@ ...@@ -359,21 +326,6 @@
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
showEnvVarsInLog = 0; showEnvVarsInLog = 0;
}; };
E1CCA95CBE6C5EE39632CCC0 /* [CP] Copy Pods Resources */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "[CP] Copy Pods Resources";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-GMCache_Example/Pods-GMCache_Example-resources.sh\"\n";
showEnvVarsInLog = 0;
};
E6007FDDD71574B978C769A2 /* [CP] Embed Pods Frameworks */ = { E6007FDDD71574B978C769A2 /* [CP] Embed Pods Frameworks */ = {
isa = PBXShellScriptBuildPhase; isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647; buildActionMask = 2147483647;
......
PODS: PODS:
- GMCache (0.2.0): - GMCache (0.2.1):
- TMCache (= 2.1.0) - TMCache (= 2.1.0)
- TMCache (2.1.0) - TMCache (2.1.0)
DEPENDENCIES: DEPENDENCIES:
- GMCache (from `../`) - GMCache (from `../`)
SPEC REPOS:
https://github.com/cocoapods/specs.git:
- TMCache
EXTERNAL SOURCES: EXTERNAL SOURCES:
GMCache: GMCache:
:path: ../ :path: "../"
SPEC CHECKSUMS: SPEC CHECKSUMS:
GMCache: b7d48432ee2469eb0c6c86c720a1958bd373187e GMCache: 776334eaa82af7b807c3420e383920d5353e4534
TMCache: 95ebcc9b3c7e90fb5fd8fc3036cba3aa781c9bed TMCache: 95ebcc9b3c7e90fb5fd8fc3036cba3aa781c9bed
PODFILE CHECKSUM: 8d482f956ed77b240df3be8144ac3958c903d882 PODFILE CHECKSUM: 8d482f956ed77b240df3be8144ac3958c903d882
COCOAPODS: 1.4.0 COCOAPODS: 1.5.3
...@@ -12,14 +12,26 @@ ...@@ -12,14 +12,26 @@
@end @end
@implementation GMCache @implementation GMCache
+ (void)storeObjectAtDiskWithkey:(NSString *)key object:(id <NSCoding>)object block:(TMDiskCacheObjectBlock)block{ + (void)storeObjectAtDiskWithkey:(NSString *)key object:(id <NSCoding>)object block:(TMDiskCacheObjectBlock)block{
NSAssert([GMCache gmCache_isNonEmpty:key], @"key不能为空");
if (![GMCache gmCache_isNonEmpty:key]) {
return;
}
[[TMCache sharedCache].diskCache setObject:object forKey:key block:block]; [[TMCache sharedCache].diskCache setObject:object forKey:key block:block];
} }
+ (void)fetchObjectAtDiskWithkey:(NSString *)key block:(TMDiskCacheObjectBlock)block{ + (void)fetchObjectAtDiskWithkey:(NSString *)key block:(TMDiskCacheObjectBlock)block{
NSAssert([GMCache gmCache_isNonEmpty:key], @"key不能为空");
if (![GMCache gmCache_isNonEmpty:key]) {
return;
}
[[TMCache sharedCache].diskCache objectForKey:key block:block]; [[TMCache sharedCache].diskCache objectForKey:key block:block];
} }
+ (void)removeObjectAtDiskWithkey:(NSString *)key block:(TMDiskCacheObjectBlock)block{ + (void)removeObjectAtDiskWithkey:(NSString *)key block:(TMDiskCacheObjectBlock)block{
NSAssert([GMCache gmCache_isNonEmpty:key], @"key不能为空");
if (![GMCache gmCache_isNonEmpty:key]) {
return;
}
[[TMCache sharedCache].diskCache removeObjectForKey:key block:block]; [[TMCache sharedCache].diskCache removeObjectForKey:key block:block];
} }
...@@ -28,14 +40,26 @@ ...@@ -28,14 +40,26 @@
} }
+ (void)storeObjectAtDiskWithkey:(NSString *)key object:(id <NSCoding>)object{ + (void)storeObjectAtDiskWithkey:(NSString *)key object:(id <NSCoding>)object{
NSAssert([GMCache gmCache_isNonEmpty:key], @"key不能为空");
if (![GMCache gmCache_isNonEmpty:key]) {
return;
}
[[TMCache sharedCache].diskCache setObject:object forKey:key]; [[TMCache sharedCache].diskCache setObject:object forKey:key];
} }
+ (id)fetchObjectAtDiskWithkey:(NSString *)key{ + (id)fetchObjectAtDiskWithkey:(NSString *)key{
return [[TMCache sharedCache].diskCache objectForKey:key]; NSAssert([GMCache gmCache_isNonEmpty:key], @"key不能为空");
if (![GMCache gmCache_isNonEmpty:key]) {
return nil;
}
return [[TMCache sharedCache].diskCache objectForKey:key];
} }
+ (void)removeObjectAtDiskWithkey:(NSString *)key{ + (void)removeObjectAtDiskWithkey:(NSString *)key{
NSAssert([GMCache gmCache_isNonEmpty:key], @"key不能为空");
if (![GMCache gmCache_isNonEmpty:key]) {
return;
}
[[TMCache sharedCache].diskCache removeObjectForKey:key]; [[TMCache sharedCache].diskCache removeObjectForKey:key];
} }
...@@ -44,14 +68,26 @@ ...@@ -44,14 +68,26 @@
} }
+ (void)storeObjectAtMemoryWithkey:(NSString *)key object:(id <NSCoding>)object block:(TMMemoryCacheObjectBlock)block{ + (void)storeObjectAtMemoryWithkey:(NSString *)key object:(id <NSCoding>)object block:(TMMemoryCacheObjectBlock)block{
NSAssert([GMCache gmCache_isNonEmpty:key], @"key不能为空");
if (![GMCache gmCache_isNonEmpty:key]) {
return;
}
[[TMCache sharedCache].memoryCache setObject:object forKey:key block:block]; [[TMCache sharedCache].memoryCache setObject:object forKey:key block:block];
} }
+ (void)fetchObjectAtMemoryWithkey:(NSString *)key block:(TMMemoryCacheObjectBlock)block{ + (void)fetchObjectAtMemoryWithkey:(NSString *)key block:(TMMemoryCacheObjectBlock)block{
NSAssert([GMCache gmCache_isNonEmpty:key], @"key不能为空");
if (![GMCache gmCache_isNonEmpty:key]) {
return;
}
[[TMCache sharedCache].memoryCache objectForKey:key block:block]; [[TMCache sharedCache].memoryCache objectForKey:key block:block];
} }
+ (void)removeObjectAtMemoryWithkey:(NSString *)key block:(TMMemoryCacheObjectBlock)block{ + (void)removeObjectAtMemoryWithkey:(NSString *)key block:(TMMemoryCacheObjectBlock)block{
NSAssert([GMCache gmCache_isNonEmpty:key], @"key不能为空");
if (![GMCache gmCache_isNonEmpty:key]) {
return;
}
[[TMCache sharedCache].memoryCache removeObjectForKey:key block:block]; [[TMCache sharedCache].memoryCache removeObjectForKey:key block:block];
} }
...@@ -60,14 +96,26 @@ ...@@ -60,14 +96,26 @@
} }
+ (void)storeObjectAtMemoryWithkey:(NSString *)key object:(id)object{ + (void)storeObjectAtMemoryWithkey:(NSString *)key object:(id)object{
NSAssert([GMCache gmCache_isNonEmpty:key], @"key不能为空");
if (![GMCache gmCache_isNonEmpty:key]) {
return;
}
[[TMCache sharedCache].memoryCache setObject:object forKey:key]; [[TMCache sharedCache].memoryCache setObject:object forKey:key];
} }
+ (id)fetchObjectAtMemoryWithkey:(NSString *)key{ + (id)fetchObjectAtMemoryWithkey:(NSString *)key{
NSAssert([GMCache gmCache_isNonEmpty:key], @"key不能为空");
if (![GMCache gmCache_isNonEmpty:key]) {
return nil;
}
return [[TMCache sharedCache].memoryCache objectForKey:key]; return [[TMCache sharedCache].memoryCache objectForKey:key];
} }
+ (void)removeObjectAtMemoryWithkey:(NSString *)key{ + (void)removeObjectAtMemoryWithkey:(NSString *)key{
NSAssert([GMCache gmCache_isNonEmpty:key], @"key不能为空");
if (![GMCache gmCache_isNonEmpty:key]) {
return;
}
[[TMCache sharedCache].memoryCache removeObjectForKey:key]; [[TMCache sharedCache].memoryCache removeObjectForKey:key];
} }
...@@ -76,18 +124,30 @@ ...@@ -76,18 +124,30 @@
} }
+ (void)storeObjectAtDocumentPathWithkey:(NSString *)key + (void)storeObjectAtDocumentPathWithkey:(NSString *)key
object:(id <NSCoding>)object object:(id <NSCoding>)object
block:(TMDiskCacheObjectBlock)block{ block:(TMDiskCacheObjectBlock)block{
NSAssert([GMCache gmCache_isNonEmpty:key], @"key不能为空");
if (![GMCache gmCache_isNonEmpty:key]) {
return;
}
[[WMDocumentCache sharedCache].diskCache setObject:object forKey:key block:block]; [[WMDocumentCache sharedCache].diskCache setObject:object forKey:key block:block];
} }
+ (void)fetchObjectAtDocumentPathWithkey:(NSString *)key + (void)fetchObjectAtDocumentPathWithkey:(NSString *)key
block:(TMDiskCacheObjectBlock)block{ block:(TMDiskCacheObjectBlock)block{
NSAssert([GMCache gmCache_isNonEmpty:key], @"key不能为空");
if (![GMCache gmCache_isNonEmpty:key]) {
return;
}
[[WMDocumentCache sharedCache].diskCache objectForKey:key block:block]; [[WMDocumentCache sharedCache].diskCache objectForKey:key block:block];
} }
+ (void)removeObjectAtDocumentPathWithkey:(NSString *)key + (void)removeObjectAtDocumentPathWithkey:(NSString *)key
block:(TMDiskCacheObjectBlock)block{ block:(TMDiskCacheObjectBlock)block{
NSAssert([GMCache gmCache_isNonEmpty:key], @"key不能为空");
if (![GMCache gmCache_isNonEmpty:key]) {
return;
}
[[WMDocumentCache sharedCache].diskCache removeObjectForKey:key block:block]; [[WMDocumentCache sharedCache].diskCache removeObjectForKey:key block:block];
} }
...@@ -96,15 +156,27 @@ ...@@ -96,15 +156,27 @@
} }
+ (void)storeObjectAtDocumentPathWithkey:(NSString *)key + (void)storeObjectAtDocumentPathWithkey:(NSString *)key
object:(id <NSCoding>)object{ object:(id <NSCoding>)object{
NSAssert([GMCache gmCache_isNonEmpty:key], @"key不能为空");
if (![GMCache gmCache_isNonEmpty:key]) {
return;
}
[[WMDocumentCache sharedCache].diskCache setObject:object forKey:key]; [[WMDocumentCache sharedCache].diskCache setObject:object forKey:key];
} }
+ (id)fetchObjectAtDocumentPathWithkey:(NSString *)key{ + (id)fetchObjectAtDocumentPathWithkey:(NSString *)key{
return [[WMDocumentCache sharedCache].diskCache objectForKey:key]; NSAssert([GMCache gmCache_isNonEmpty:key], @"key不能为空");
if (![GMCache gmCache_isNonEmpty:key]) {
return nil;
}
return [[WMDocumentCache sharedCache].diskCache objectForKey:key];
} }
+ (void)removeObjectAtDocumentPathWithkey:(NSString *)key{ + (void)removeObjectAtDocumentPathWithkey:(NSString *)key{
NSAssert([GMCache gmCache_isNonEmpty:key], @"key不能为空");
if (![GMCache gmCache_isNonEmpty:key]) {
return;
}
[[WMDocumentCache sharedCache].diskCache removeObjectForKey:key]; [[WMDocumentCache sharedCache].diskCache removeObjectForKey:key];
} }
...@@ -112,6 +184,18 @@ ...@@ -112,6 +184,18 @@
[[WMDocumentCache sharedCache].diskCache removeAllObjects]; [[WMDocumentCache sharedCache].diskCache removeAllObjects];
} }
+ (BOOL)gmCache_isNonEmpty:(NSString *)key {
NSMutableCharacterSet *emptyStringSet = [[NSMutableCharacterSet alloc] init];
[emptyStringSet formUnionWithCharacterSet: [NSCharacterSet whitespaceAndNewlineCharacterSet]];
[emptyStringSet formUnionWithCharacterSet: [NSCharacterSet characterSetWithCharactersInString: @" "]];
if ([key length] == 0) {
return NO;
}
NSString* str = [key stringByTrimmingCharactersInSet:emptyStringSet];
return [str length] > 0;
}
@end @end
NSString * const WMCacheSharedName = @"WMCacheShared"; NSString * const WMCacheSharedName = @"WMCacheShared";
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment