-
Notifications
You must be signed in to change notification settings - Fork 0
/
ASICacheDelegate.h
55 lines (41 loc) · 2.09 KB
/
ASICacheDelegate.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
//
// ASICacheDelegate.h
// Part of ASIHTTPRequest -> http://allseeing-i.com/ASIHTTPRequest
//
// Created by Ben Copsey on 01/05/2010.
// Copyright 2010 All-Seeing Interactive. All rights reserved.
//
#import <Foundation/Foundation.h>
@class ASIHTTPRequest;
typedef enum _ASICachePolicy {
ASIDefaultCachePolicy = 0,
ASIIgnoreCachePolicy = 1,
ASIReloadIfDifferentCachePolicy = 2,
ASIOnlyLoadIfNotCachedCachePolicy = 3,
ASIUseCacheIfLoadFailsCachePolicy = 4
} ASICachePolicy;
typedef enum _ASICacheStoragePolicy {
ASICacheForSessionDurationCacheStoragePolicy = 0,
ASICachePermanentlyCacheStoragePolicy = 1
} ASICacheStoragePolicy;
@protocol ASICacheDelegate <NSObject>
@required
// Should return the cache policy that will be used when requests have their cache policy set to ASIDefaultCachePolicy
- (ASICachePolicy)defaultCachePolicy;
// Should Remove cached data for a particular request
- (void)removeCachedDataForRequest:(ASIHTTPRequest *)request;
// Should return YES if the cache considers its cached response current for the request
// Should return NO is the data is not cached, or (for example) if the cached headers state the request should have expired
- (BOOL)isCachedDataCurrentForRequest:(ASIHTTPRequest *)request;
// Should store the response for the passed request in the cache
// When a non-zero maxAge is passed, it should be used as the expiry time for the cached response
- (void)storeResponseForRequest:(ASIHTTPRequest *)request maxAge:(NSTimeInterval)maxAge;
// Should return an NSDictionary of cached headers for the passed request, if it is stored in the cache
- (NSDictionary *)cachedHeadersForRequest:(ASIHTTPRequest *)request;
// Should return the cached body of a response for the passed request, if it is stored in the cache
- (NSData *)cachedResponseDataForRequest:(ASIHTTPRequest *)request;
// Same as the above, but returns a path to the cached response body instead
- (NSString *)pathToCachedResponseDataForRequest:(ASIHTTPRequest *)request;
// Clear cached data stored for the passed storage policy
- (void)clearCachedResponsesForStoragePolicy:(ASICacheStoragePolicy)cachePolicy;
@end