CTNetworking icon indicating copy to clipboard operation
CTNetworking copied to clipboard

不能缓存没有参数的API请求吗?

Open gaojinhsu opened this issue 4 years ago • 1 comments

- (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为空就没办法缓存了。处于什么考虑呢?

gaojinhsu avatar Apr 15 '20 11:04 gaojinhsu

这个主要是我当时的业务场景导致做了这样的决定,因为我们当时业务上那些没有参数的API都是不应该缓存的,它每次访问可能数据都不一样。

你可以按照你的业务场景来做调整。

casatwy avatar Apr 15 '20 11:04 casatwy