CTNetworking
CTNetworking copied to clipboard
不能缓存没有参数的API请求吗?
- (void)saveMemoryCacheWithResponse:(CTURLResponse *)response serviceIdentifier:(NSString *)serviceIdentifier methodName:(NSString *)methodName cacheTime:(NSTimeInterval)cacheTime { if (response.originRequestParams && response.content && serviceIdentifier && methodName) { [self.memoryCacheCenter saveCacheWithResponse:response key:[self keyWithServiceIdentifier:serviceIdentifier methodName:methodName requestParams:response.originRequestParams] cacheTime:cacheTime]; } }
请求没有参数时,originRequestParams
为空就没办法缓存了。处于什么考虑呢?
这个主要是我当时的业务场景导致做了这样的决定,因为我们当时业务上那些没有参数的API都是不应该缓存的,它每次访问可能数据都不一样。
你可以按照你的业务场景来做调整。