Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
This repository was archived by the owner on Apr 5, 2021. It is now read-only.
/ ECDataCache Public archive

A generic NSData cache backed by NSCache for in-memory data.

License

Notifications You must be signed in to change notification settings

educreations/ECDataCache

Open more actions menu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ECDataCache

A generic NSData cache for storing data to disk, which is backed by NSCache for in-memory data.

Usage

Just include the header somewhere up top:

#import "ECDataCache.h"

Then use it in your code like so:

NSData *someData = [ECDataCache.sharedCache dataForKey:@"some key"];
if (someData) {
    // Do stuff with someData
} else {
    // someData doesn't exist
}

You can also use it with URLs to store and load images. For example:

NSURL *url = [NSURL URLWithString:@"http://www.educreations.com/static/images/logo/logo-large-dark.png"];
NSData *data = [ECDataCache.sharedCache dataForURL:url];
if (data) {
    // We are good to go
    UIImage *image = [UIImage imageWithData:data];
} else {
    // Fetch the url
    ...

    // On successful fetch, store the image to disk
    [ECDataCache.sharedCache setData:data forURL:url];
}

License

Uses the MIT license.

About

A generic NSData cache backed by NSCache for in-memory data.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •  
Morty Proxy This is a proxified and sanitized view of the page, visit original site.