seatgeek/SGImageCache — an open-source project — sits at 401 GitHub stars. A flexible image caching library for image rich iOS applications
Snapshot summary built from the project's own GitHub metadata — there's no written TopGit review yet. The page will update automatically when a full review is published.
WHY NO REVIEW YET
TopGit writes full reviews for the most-starred, most-requested repositories. This page is a snapshot until then — see the READ ME tab for the original README in full.
// Swift
SGImageCache.getImage(url: url) { [weak self] image in
guard let self = self else { return }
self.imageView.image = image
}
This will add the fetch request to fastQueue (a parellel queue). All image fetching (either
from memory, disk, or remote) is performed off the main thread.
This will add the fetch request to slowQueue (a serial queue). All image fetching (either
from memory, disk, or remote) is performed off the main thread.
Adding image fetch tasks to slowQueue is useful for prefetching images for off screen
content. For example if you have data for 100 table rows, but only 3 are on screen at a time,
you would request the images for on screen rows from fastQueue with getImageForURL: and
add the rest to slowQueue with slowGetImageForURL:.
Inform the cache that an urgent image fetch is no longer urgent
// Swift
SGImageCache.moveTaskToSlowQueueForURL(url)
This is useful for deprioritising image fetches for content that has scrolled off screen. The
content may scroll back on screen later, so you still want the fetch to happen, but it is no
longer urgently required.
Perform actions on remote fetch, fail or retry
// Objective-C
SGCachePromise *promise = [SGImageCache getImageForURL:url];
promise.then(^(UIImage *image) {
self.imageView.image = image;
});
promise.onRetry = ^{
// Called when SGImageCache automatically retries
// fetching the image due to a reachability change.
[self showLoadingSpinner];
};
promise.onFail = ^(NSError *error, BOOL fatal) {
// If the failure was fatal, SGImageCache will not
// automatically retry (eg. from a 404)
[self displayError:error];
};
// Swift
let promise = SGImageCache.getImageForURL(url)
promise.swiftThen({object in
if let image = object as? UIImage {
self.imageView.image = image
}
return nil
})
promise.onRetry = {
self.showLoadingSpinner()
}
promise.onFail = { (error: NSError?, wasFatal: Bool) -> () in
self.displayError(error)
}
This is useful for displaying states of network failure, loading spinners on reachability change, or any other functionality that might need to be notified that an image could not be fetched.
fastQueue
fastQueue is a parallel queue, used for urgently required images. The getImageForURL:
method adds tasks to this queue. The maximum number of parallel tasks is managed by iOS, based on the device's number of processors, and other factors.
slowQueue
slowQueue is a serial queue, used for prefetching images that might be required later (eg
for currently off screen content). The slowGetImageForURL: method adds tasks to this queue.
slowQueue is automatically suspended while fastQueue is active, to avoid consuming network bandwidth while urgent image fetches are in progress. Once all fastQueue tasks are completed
slowQueue will be resumed.
Task Deduplication
If an image is requested for a URL that is already queued or in progress, SGImageCache
reuses the existing task, and if necessary will move it from slowQueue to fastQueue,
depending on which image fetch method was used. This ensures that there will be only one
network request per URL, regardless of how many times it's been asked for.
Intelligent image releasing on memory warning
If you use SGImageView instead of UIImageView, and load the image via one of the
setImageForURL: methods, off screen image views will release their image on memory
warning, and subsequently restore them from cache if the image view returns to screen.
This allows off screen but still existing view controllers (eg a previous controller in a
nav controller's stack) to free up memory that would otherwise be unnecessarily retained,
and reduce the chances of your app being terminated by iOS in limited memory situations.
Generic caching of NSData
You can use SGImageCache for caching of generic data in the form of an NSData object (eg. PDFs, JSON payloads). Just use the equivalent SGCache class method instead of the SGImageCache one:
// Objective-C
[SGCache getFileForURL:url].then(^(NSData *data) {
// do something with data
});
// Swift
SGCache.getFileForURL(url).swiftThen({object in
if let data = object as? NSData {
// do something with data
}
return nil
})
Does seatgeek/SGImageCache have a project website?
No homepage URL was recorded for seatgeek/SGImageCache in TopGit's last sync. The README tab above frequently contains screenshots and demo links, or check the repository description on GitHub.
Does seatgeek/SGImageCache have any tags?
TopGit's last sync did not record any GitHub topics for seatgeek/SGImageCache. GitHub topics appear in the right sidebar of a repository page; that's the authoritative place to check.
How active is development on seatgeek/SGImageCache?
The most recent commit recorded on seatgeek/SGImageCache was 6.4 years ago, based on the GitHub push timestamp. The repository has 35 forks — one of the better signals of community interest.
How many stars does seatgeek/SGImageCache have?
seatgeek/SGImageCache has 401 GitHub stars — refresh the page for the live number, or check github.com/seatgeek/SGImageCache. TopGit mirrors GitHub's count but does not claim minute-by-minute accuracy.
What language is seatgeek/SGImageCache written in?
seatgeek/SGImageCache is written primarily in Objective-C. GitHub's language field is based on the largest share of bytes in the default branch.
What license does seatgeek/SGImageCache use?
seatgeek/SGImageCache is released under the BSD-2-Clause license. Always verify the LICENSE file directly on GitHub for the authoritative terms — license strings can be edited out of sync with a project's actual stance.
Where do I read more about seatgeek/SGImageCache?
This TopGit page is a snapshot — the READ ME tab shows the project's own README content (links stripped, images preserved). The GitHub repository at github.com/seatgeek/SGImageCache is the definitive source.
Read full README in the tab above.
Is SGImageCache worth your time?
ChatGPT, Claude and Perplexity can all read this page. Ask one of them what it makes of SGImageCache.