Skip to content
This repository has been archived by the owner on Aug 24, 2019. It is now read-only.

soffes/SAMCache

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

49 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SAMCache

Carthage compatible

Simple in memory and on disk cache. It's backed by an NSCache in memory, so it automatically purges itself when memory gets low. Purged memory keys will automatically be loaded from disk the next time the are requested.

Usage

The API is simple.

- (id)objectForKey:(NSString *)key;
- (void)objectForKey:(NSString *)key usingBlock:(void (^)(id <NSCopying> object))block;
- (void)setObject:(id <NSCopying>)object forKey:(NSString *)key;

You can also use subscripts:

SAMCache *cache = [SAMCache sharedCache];
cache[@"answer"] = @42;
NSLog(@"The answer is %@", cache[@"answer"]);

See SAMCache.h for the full list of methods.

Adding to Your Project

Simply add SAMCache.h and SAMCache.m to your project or if you're using CocoaPods, simply add 'SAMCache' to your Podfile.

About

Fancy caching with on-disk persistence

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Objective-C 94.1%
  • Ruby 5.9%