Conforms to NSObject
Declared in SPTDiskCaching.h

Instance Methods

allocateCacheWithKey:size:

Creates a disk cache of certain size or changes the size of an existing cache.

- (BOOL)allocateCacheWithKey:(NSString *)key size:(NSUInteger)size

Parameters

key

An alphanumeric string, through which the cache is identified and accessed via ‘SPTDiskCaching’ methods.

size

The requested amount of bytes in the cache.

Return Value

YES if the cache of requested size has been allocated successfully, otherwise NO.

Discussion

This method will be called when a new cache needs to be created or when the size of an existing cache needs to be changed. The cache should be accessible via other ‘SPTDiskCaching’ methods when using the same key as provided in this method.

Declared In

SPTDiskCaching.h

closeCacheWithKey:

Closes the existing disk cache.

- (void)closeCacheWithKey:(NSString *)key

Parameters

key

The identifier of the cache.

Discussion

This method will be called when a cache is no longer needed and can be deleted.

Declared In

SPTDiskCaching.h

readCacheDataWithKey:length:offset:

Reads data from the existing disk cache.

- (NSData *)readCacheDataWithKey:(NSString *)key length:(NSUInteger)length offset:(NSUInteger)offset

Parameters

key

The identifier of the cache.

length

The amount of bytes to be read from the cache.

offset

The amount of bytes to be skipped from the beginning of the cache before reading starts.

Return Value

An instance of NSData containing the data read from the cache; ‘nil’ if reading failed.

Discussion

This method will be called whenever a data needs to be read from the existing disk cache. The cache is identified by its key.

Declared In

SPTDiskCaching.h

writeCacheDataWithKey:data:offset:

Writes data to the existing disk cache.

- (BOOL)writeCacheDataWithKey:(NSString *)key data:(NSData *)data offset:(NSUInteger)offset

Parameters

key

The identifier of the cache.

data

Bytes to be written to the cache.

offset

The amount of bytes to be skipped from the beginning of the cache before writing starts.

Return Value

YES if writing to the cache has been successful, otherwise ‘NO’.

Discussion

This method will be called whenever a data needs to be written to the existing disk cache. The cache is identified by its key.

Declared In

SPTDiskCaching.h