Inherits from NSObject
Declared in SDImageCache.h
SDImageCache.m

Overview

SDImageCache maintains a memory cache and an optional disk cache. Disk cache write operations are performed asynchronous so it doesn’t add unnecessary latency to the UI.

Tasks

Properties

maxCacheAge

The maximum length of time to keep an image in the cache, in seconds

@property (assign, nonatomic) NSInteger maxCacheAge

Discussion

The maximum length of time to keep an image in the cache, in seconds

Declared In

SDImageCache.h

Class Methods

sharedImageCache

Returns global shared cache instance

+ (SDImageCache *)sharedImageCache

Return Value

SDImageCache global instance

Discussion

Returns global shared cache instance

Declared In

SDImageCache.h

Instance Methods

cleanDisk

Remove all expired cached image from disk

- (void)cleanDisk

Discussion

Remove all expired cached image from disk

Declared In

SDImageCache.h

clearDisk

Clear all disk cached images

- (void)clearDisk

Discussion

Clear all disk cached images

Declared In

SDImageCache.h

clearMemory

Clear all memory cached images

- (void)clearMemory

Discussion

Clear all memory cached images

Declared In

SDImageCache.h

getDiskCount

Get the number of images in the disk cache

- (int)getDiskCount

Discussion

Get the number of images in the disk cache

Declared In

SDImageCache.h

getSize

Get the size used by the disk cache

- (int)getSize

Discussion

Get the size used by the disk cache

Declared In

SDImageCache.h

imageFromDiskCacheForKey:

Query the disk cache synchronousely.

- (UIImage *)imageFromDiskCacheForKey:(NSString *)key

Parameters

key

The unique key used to store the wanted image

Discussion

Query the disk cache synchronousely.

Declared In

SDImageCache.h

imageFromMemoryCacheForKey:

Query the memory cache.

- (UIImage *)imageFromMemoryCacheForKey:(NSString *)key

Parameters

key

The unique key used to store the wanted image

Discussion

Query the memory cache.

Declared In

SDImageCache.h

initWithNamespace:

Init a new cache store with a specific namespace

- (id)initWithNamespace:(NSString *)ns

Parameters

ns

The namespace to use for this cache store

Discussion

Init a new cache store with a specific namespace

Declared In

SDImageCache.h

queryDiskCacheForKey:done:

Query the disk cache asynchronousely.

- (void)queryDiskCacheForKey:(NSString *)key done:(void ( ^ ) ( UIImage *image , SDImageCacheType cacheType ))doneBlock

Parameters

key

The unique key used to store the wanted image

Discussion

Query the disk cache asynchronousely.

Declared In

SDImageCache.h

removeImageForKey:

Remove the image from memory and disk cache synchronousely

- (void)removeImageForKey:(NSString *)key

Parameters

key

The unique image cache key

Discussion

Remove the image from memory and disk cache synchronousely

Declared In

SDImageCache.h

removeImageForKey:fromDisk:

Remove the image from memory and optionaly disk cache synchronousely

- (void)removeImageForKey:(NSString *)key fromDisk:(BOOL)fromDisk

Parameters

key

The unique image cache key

fromDisk

Also remove cache entry from disk if YES

Discussion

Remove the image from memory and optionaly disk cache synchronousely

Declared In

SDImageCache.h

storeImage:forKey:

Store an image into memory and disk cache at the given key.

- (void)storeImage:(UIImage *)image forKey:(NSString *)key

Parameters

image

The image to store

key

The unique image cache key, usually it’s image absolute URL

Discussion

Store an image into memory and disk cache at the given key.

Declared In

SDImageCache.h

storeImage:forKey:toDisk:

Store an image into memory and optionally disk cache at the given key.

- (void)storeImage:(UIImage *)image forKey:(NSString *)key toDisk:(BOOL)toDisk

Parameters

image

The image to store

key

The unique image cache key, usually it’s image absolute URL

toDisk

Store the image to disk cache if YES

Discussion

Store an image into memory and optionally disk cache at the given key.

Declared In

SDImageCache.h

storeImage:imageData:forKey:toDisk:

Store an image into memory and optionally disk cache at the given key.

- (void)storeImage:(UIImage *)image imageData:(NSData *)data forKey:(NSString *)key toDisk:(BOOL)toDisk

Parameters

image

The image to store

data

The image data as returned by the server, this representation will be used for disk storage instead of converting the given image object into a storable/compressed image format in order to save quality and CPU

key

The unique image cache key, usually it’s image absolute URL

toDisk

Store the image to disk cache if YES

Discussion

Store an image into memory and optionally disk cache at the given key.

Declared In

SDImageCache.h