Ignite Tools
Shared/Airship/External/UA_asi-http-request/UA_ASICacheDelegate.h
00001 //
00002 //  UA_ASICacheDelegate.h
00003 //  Part of UA_ASIHTTPRequest -> http://allseeing-i.com/ASIHTTPRequest
00004 //
00005 //  Created by Ben Copsey on 01/05/2010.
00006 //  Copyright 2010 All-Seeing Interactive. All rights reserved.
00007 //
00008 
00009 #import <Foundation/Foundation.h>
00010 @class UA_ASIHTTPRequest;
00011 
00012 // Cache policies control the behaviour of a cache and how requests use the cache
00013 // When setting a cache policy, you can use a combination of these values as a bitmask
00014 // For example: [request setCachePolicy:UA_ASIAskServerIfModifiedCachePolicy|UA_ASIFallbackToCacheIfLoadFailsCachePolicy|UA_ASIDoNotWriteToCacheCachePolicy];
00015 // Note that some of the behaviours below are mutally exclusive - you cannot combine UA_ASIAskServerIfModifiedWhenStaleCachePolicy and UA_ASIAskServerIfModifiedCachePolicy, for example.
00016 typedef enum _UA_ASICachePolicy {
00017 
00018         // The default cache policy. When you set a request to use this, it will use the cache's defaultCachePolicy
00019         // UA_ASIDownloadCache's default cache policy is 'UA_ASIAskServerIfModifiedWhenStaleCachePolicy'
00020         UA_ASIUseDefaultCachePolicy = 0,
00021 
00022         // Tell the request not to read from the cache
00023         UA_ASIDoNotReadFromCacheCachePolicy = 1,
00024 
00025         // The the request not to write to the cache
00026         UA_ASIDoNotWriteToCacheCachePolicy = 2,
00027 
00028         // Ask the server if there is an updated version of this resource (using a conditional GET) ONLY when the cached data is stale
00029         UA_ASIAskServerIfModifiedWhenStaleCachePolicy = 4,
00030 
00031         // Always ask the server if there is an updated version of this resource (using a conditional GET)
00032         UA_ASIAskServerIfModifiedCachePolicy = 8,
00033 
00034         // If cached data exists, use it even if it is stale. This means requests will not talk to the server unless the resource they are requesting is not in the cache
00035         UA_ASIOnlyLoadIfNotCachedCachePolicy = 16,
00036 
00037         // If cached data exists, use it even if it is stale. If cached data does not exist, stop (will not set an error on the request)
00038         UA_ASIDontLoadCachePolicy = 32,
00039 
00040         // Specifies that cached data may be used if the request fails. If cached data is used, the request will succeed without error. Usually used in combination with other options above.
00041         UA_ASIFallbackToCacheIfLoadFailsCachePolicy = 64
00042 } UA_ASICachePolicy;
00043 
00044 // Cache storage policies control whether cached data persists between application launches (UA_ASICachePermanentlyCacheStoragePolicy) or not (UA_ASICachePermanentlyCacheStoragePolicy)
00045 // Calling [UA_ASIHTTPRequest clearSession] will remove any data stored using UA_ASICacheForSessionDurationCacheStoragePolicy
00046 typedef enum _UA_ASICacheStoragePolicy {
00047         UA_ASICacheForSessionDurationCacheStoragePolicy = 0,
00048         UA_ASICachePermanentlyCacheStoragePolicy = 1
00049 } UA_ASICacheStoragePolicy;
00050 
00051 
00052 @protocol UA_ASICacheDelegate <NSObject>
00053 
00054 @required
00055 
00056 // Should return the cache policy that will be used when requests have their cache policy set to ASIDefaultCachePolicy
00057 - (UA_ASICachePolicy)defaultCachePolicy;
00058 
00059 - (BOOL)canUseCachedDataForRequest:(UA_ASIHTTPRequest *)request;
00060 
00061 // Should Remove cached data for a particular request
00062 - (void)removeCachedDataForRequest:(UA_ASIHTTPRequest *)request;
00063 
00064 // Should return YES if the cache considers its cached response current for the request
00065 // Should return NO is the data is not cached, or (for example) if the cached headers state the request should have expired
00066 - (BOOL)isCachedDataCurrentForRequest:(UA_ASIHTTPRequest *)request;
00067 
00068 // Should store the response for the passed request in the cache
00069 // When a non-zero maxAge is passed, it should be used as the expiry time for the cached response
00070 - (void)storeResponseForRequest:(UA_ASIHTTPRequest *)request maxAge:(NSTimeInterval)maxAge;
00071 
00072 // Should return an NSDictionary of cached headers for the passed URL, if it is stored in the cache
00073 - (NSDictionary *)cachedResponseHeadersForURL:(NSURL *)url;
00074 
00075 // Should return the cached body of a response for the passed URL, if it is stored in the cache
00076 - (NSData *)cachedResponseDataForURL:(NSURL *)url;
00077 
00078 // Returns a path to the cached response data, if it exists
00079 - (NSString *)pathToCachedResponseDataForURL:(NSURL *)url;
00080 
00081 // Returns a path to the cached response headers, if they url
00082 - (NSString *)pathToCachedResponseHeadersForURL:(NSURL *)request;
00083 
00084 // Returns the location to use to store cached response headers for a particular request
00085 - (NSString *)pathToStoreCachedResponseHeadersForRequest:(UA_ASIHTTPRequest *)request;
00086 
00087 // Returns the location to use to store a cached response body for a particular request
00088 - (NSString *)pathToStoreCachedResponseDataForRequest:(UA_ASIHTTPRequest *)request;
00089 
00090 // Clear cached data stored for the passed storage policy
00091 - (void)clearCachedResponsesForStoragePolicy:(UA_ASICacheStoragePolicy)cachePolicy;
00092 
00093 @end
 All Classes Functions Variables Properties