forked from RestKit/RestKit
/
RKRequestCache.h
60 lines (42 loc) · 1.84 KB
/
RKRequestCache.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
//
// RKRequestCache.h
// RestKit
//
// Created by Jeff Arena on 4/4/11.
// Copyright 2011 Two Toasters. All rights reserved.
//
#import "RKRequest.h"
#import "RKResponse.h"
/**
* Storage policy. Determines if we clear the cache out when the app is shut down.
* Cache instance needs to register for
*/
typedef enum {
RKRequestCacheStoragePolicyDisabled, // The cache has been disabled. Attempts to store data will silently fail
RKRequestCacheStoragePolicyForDurationOfSession, // Cache data for the length of the session. Clear cache at app exit.
RKRequestCacheStoragePolicyPermanently // Cache data permanently, until explicitly expired or flushed
} RKRequestCacheStoragePolicy;
/**
Stores and retrieves cache entries for RestKit request objects.
*/
@interface RKRequestCache : NSObject {
NSString* _cachePath;
RKRequestCacheStoragePolicy _storagePolicy;
NSRecursiveLock* _cacheLock;
}
@property (nonatomic, readonly) NSString* cachePath; // Full path to the cache
@property (nonatomic, assign) RKRequestCacheStoragePolicy storagePolicy; // User can change storage policy.
+ (NSDateFormatter*)rfc1123DateFormatter;
- (id)initWithCachePath:(NSString*)cachePath storagePolicy:(RKRequestCacheStoragePolicy)storagePolicy;
- (NSString*)pathForRequest:(RKRequest*)request;
- (BOOL)hasResponseForRequest:(RKRequest*)request;
- (void)storeResponse:(RKResponse*)response forRequest:(RKRequest*)request;
- (RKResponse*)responseForRequest:(RKRequest*)request;
- (NSDictionary*)headersForRequest:(RKRequest*)request;
- (NSString*)etagForRequest:(RKRequest*)request;
- (NSDate*)cacheDateForRequest:(RKRequest*)request;
- (void)setCacheDate:(NSDate*)date forRequest:(RKRequest*)request;
- (void)invalidateRequest:(RKRequest*)request;
- (void)invalidateWithStoragePolicy:(RKRequestCacheStoragePolicy)storagePolicy;
- (void)invalidateAll;
@end