Latest 0.1.7
License MIT
Platforms ios 8.0
Dependencies HMCThreadSafeMutableCollection, HMCDownloadManager
Frameworks UIKit, ImageIO

Build Status

Component Libraries

HMCThreadSafeMutableCollection provides thread safe array and dictionary
HMCDownloadManager provides APIs for downloading image from URL


  • iOS 8.0+
  • Xcode 8.3+


  • [x] Caching image on disk
  • [x] Caching image on memory
  • [x] Balancing I/O read write and memory usage
  • [x] Auto adjusting memory usage based on avaiable memory (5% of available mem in background, 80% of available mem in foreground)
  • [x] Release memory by LRU algorithm
  • [x] Auto remove unsued cache files on disk after 30 days
  • [x] Get image from url with target size
  • [x] Set UIImageView with image from URL
  • [x] Set UIButton with image from URL


HMCImageCache is available through CocoaPods. To install
it, simply add the following line to your Podfile:

pod 'HMCImageCache'


Singleton object

To get image caching instance:

HMCImageCache *imageCache = [HMCImageCache sharedInstance];

To store image to cache

UIImage *image = ...;
NSString *identifier = ...;
[imageCache storeImage:image withKey:identifier];

To get origin image from cache

image = [imageCache imageFromKey:identifier storeToMem:YES];  // storeToMem: do you want image store to memory

To get image with target size

CGSize size = CGSizeMake(300,400); // Image with size 300px x 400 px
image = [imageCache imageFromKey:identifier withSize:size];

To get image from URL

[imageCache imageFromURL:url
              completion:^(UIImage *image){
                  // do something with image

To set image to UIImageView from URL

NSURL *url;
UIImageView *imageView;
[imageView HMCSetImageFromURL:url forState: UIControlStateNormal];

To set image to UIButton from URL

NSURL *url;
UIButton *button;

To remove an image from cache

[imageCache removeImageForKey:identifier];

To remove all images from cache

[imageCache removeAllCache];


chuonghuynh, [email protected]


HMCImageCache is available under the MIT license. See the LICENSE file for more info.

Latest podspec

    "name": "HMCImageCache",
    "version": "0.1.7",
    "summary": "Support caching images balancing between I/O and memory with LRU algorithm",
    "description": "HMCImageCache is a utility supporting caching images with balancing between I/O read write and memory usage by LRU (Least recently use) algorithm as well as calculating available memory size. It also support generating UIImage with target size.",
    "homepage": "",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    "authors": {
        "Chuong M. Huynh": "[email protected]"
    "source": {
        "git": "",
        "tag": "0.1.7"
    "platforms": {
        "ios": "8.0"
    "source_files": "HMCImageCache/Classes/**/*",
    "public_header_files": "HMCImageCache/Classes/**/*.h",
    "frameworks": [
    "dependencies": {
        "HMCThreadSafeMutableCollection": [
            "~> 0.1.0"
        "HMCDownloadManager": [
            "~> 0.1.0"

Pin It on Pinterest

Share This