{"id":27108586,"url":"https://github.com/hmchuong/ios-objectivec-hmcimagecache","last_synced_at":"2025-04-06T22:21:15.999Z","repository":{"id":56913662,"uuid":"107071632","full_name":"hmchuong/iOS-ObjectiveC-HMCImageCache","owner":"hmchuong","description":"Support caching images balancing between I/O and memory with LRU algorithm","archived":false,"fork":false,"pushed_at":"2018-03-31T08:46:16.000Z","size":204,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-05T09:18:17.105Z","etag":null,"topics":["cocoapods","imagecache","ios","objective-c","xcode"],"latest_commit_sha":null,"homepage":null,"language":"Objective-C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hmchuong.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-10-16T03:02:09.000Z","updated_at":"2017-11-13T14:00:52.000Z","dependencies_parsed_at":"2022-08-21T03:20:25.809Z","dependency_job_id":null,"html_url":"https://github.com/hmchuong/iOS-ObjectiveC-HMCImageCache","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hmchuong%2FiOS-ObjectiveC-HMCImageCache","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hmchuong%2FiOS-ObjectiveC-HMCImageCache/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hmchuong%2FiOS-ObjectiveC-HMCImageCache/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hmchuong%2FiOS-ObjectiveC-HMCImageCache/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hmchuong","download_url":"https://codeload.github.com/hmchuong/iOS-ObjectiveC-HMCImageCache/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247558676,"owners_count":20958201,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cocoapods","imagecache","ios","objective-c","xcode"],"created_at":"2025-04-06T22:21:15.279Z","updated_at":"2025-04-06T22:21:15.991Z","avatar_url":"https://github.com/hmchuong.png","language":"Objective-C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# HMCImageCache\n\n[![Build Status](https://travis-ci.org/hmchuong/iOS-ObjectiveC-HMCImageCache.svg?branch=master)](https://travis-ci.org/hmchuong/iOS-ObjectiveC-HMCImageCache)\n[![Version](https://img.shields.io/cocoapods/v/HMCImageCache.svg?style=flat)](http://cocoapods.org/pods/HMCImageCache)\n[![License](https://img.shields.io/cocoapods/l/HMCImageCache.svg?style=flat)](http://cocoapods.org/pods/HMCImageCache)\n[![Platform](https://img.shields.io/cocoapods/p/HMCImageCache.svg?style=flat)](http://cocoapods.org/pods/HMCImageCache)\n\n## Component Libraries\n[HMCThreadSafeMutableCollection](http://cocoapods.org/pods/HMCThreadSafeMutableCollection) provides thread safe array and dictionary  \n[HMCDownloadManager](http://cocoapods.org/pods/HMCDownloadManager) provides APIs for downloading image from URL\n## Requirements\n- iOS 8.0+\n- Xcode 8.3+\n\n## Features\n- [x] Caching image on disk\n- [x] Caching image on memory\n- [x] Balancing I/O read write and memory usage\n- [x] Auto adjusting memory usage based on avaiable memory *(5% of available mem in background, 80% of available mem in foreground)* \n- [x] Release memory by LRU algorithm\n- [x] Auto remove unsued cache files on disk after 30 days \n- [x] Get image from url with target size\n- [x] Set UIImageView with image from URL\n- [x] Set UIButton with image from URL\n\n## Installation\n\nHMCImageCache is available through [CocoaPods](http://cocoapods.org). To install\nit, simply add the following line to your Podfile:\n\n```ruby\npod 'HMCImageCache'\n```\n## Usage\n\n### Singleton object\nTo get image caching instance:\n```ObjectiveC\nHMCImageCache *imageCache = [HMCImageCache sharedInstance];\n```\n\n### To store image to cache\n```ObjectiveC\nUIImage *image = ...;\nNSString *identifier = ...;\n[imageCache storeImage:image withKey:identifier];\n```\n\n### To get origin image from cache\n```ObjectiveC\nimage = [imageCache imageFromKey:identifier storeToMem:YES];  // storeToMem: do you want image store to memory\n```\n\n### To get image with target size\n```ObjectiveC\nCGSize size = CGSizeMake(300,400); // Image with size 300px x 400 px\nimage = [imageCache imageFromKey:identifier withSize:size];\n```\n\n### To get image from URL\n```ObjectiveC\n[imageCache imageFromURL:url\n          withTargetSize:CGSizeMake(300,400)\n              completion:^(UIImage *image){\n                  // do something with image\n              }\n           callbackQueue:dispatch_get_main_queue()];\n```\n\n### To set image to UIImageView from URL\n```ObjectiveC\nNSURL *url;\nUIImageView *imageView;\n[imageView HMCSetImageFromURL:url forState: UIControlStateNormal];\n```\n\n### To set image to UIButton from URL\n```ObjectiveC\nNSURL *url;\nUIButton *button;\n[button HMCSetImageFromURL:url forState: UIControlStateNormal];\n```\n\n### To remove an image from cache\n```ObjectiveC\n[imageCache removeImageForKey:identifier];\n```\n\n### To remove all images from cache\n```ObjectiveC\n[imageCache removeAllCache];\n```\n\n## Author\n\nchuonghuynh, minhchuong.itus@gmail.com\n\n## License\n\nHMCImageCache is available under the MIT license. See the LICENSE file for more info.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhmchuong%2Fios-objectivec-hmcimagecache","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhmchuong%2Fios-objectivec-hmcimagecache","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhmchuong%2Fios-objectivec-hmcimagecache/lists"}