Latest 0.1
Homepage https://github.com/leverdeterre/JMCache
License MIT
Platforms ios 6.0, requires ARC
Authors

JMCache is a key/value store designed for persisting temporary objects fully based on GCD.
It is composed of a cache disk and a memory cache (JMCacheMemory).

JMCache is cool because :

  • it can store object not compliant with NSCoding protocols, you can implement JMcoding protocol or use FastCoding implementation,
  • you can configure the cache to be "memory then disk", "only memory", "only disk",
  • you can use a ValueTransformer to increase security of your encoded object, you can zip it, crypt it with your own algorithms.

Installation & Usage

If using CocoaPods, the quickest way to try it out is to type this on the command line:

$ pod try JMCache

Cache parameters

Cache path type -> auto path to the save directory

typedef NS_ENUM(NSUInteger, JMCacheType) {
    JMCacheTypePublic,
    JMCacheTypePrivate,
    JMCacheTypeOffline
};

Cache type -> memory, disk

typedef NS_OPTIONS(NSUInteger, JMCacheType) {
    JMCacheTypeInMemory = 1,
    JMCacheTypeOnDisk   = 1 << 1,
    JMCacheTypeInMemoryThenOnDisk   = (JMCacheTypeInMemory | JMCacheTypeOnDisk)
};

ValueTransformer

You can write your own valueTransformer to increase security of your encoded data.
For example, see minimalist implemtation of JMCacheReverseDataValueTransformer class.

@property (strong, nonatomic) JMCacheValueTransformer *valueTransformer;

API

// Async API
- (void)objectForKey:(NSString *)key withCompletionBlock:(JMCacheCompletionBlockObjectError)block;
- (void)setObject:(NSObject *)obj forKey:(NSString *)key withCompletionBlock:(JMCacheCompletionBlockBoolError)block;
- (void)removeObjectForKey:(NSString *)key withCompletionBlock:(JMCacheCompletionBlockBoolError)block;
- (void)clearCacheWithCompletionBlock:(JMCacheCompletionBlockBool)block;

// Sync API
- (id)objectForKey:(NSString *)key;
- (BOOL)setObject:(NSObject *)obj forKey:(NSString *)key;
- (NSInteger)numberOfCachedObjects;

Latest podspec

{
    "name": "JMCache",
    "version": "0.1",
    "requires_arc": true,
    "authors": {
        "Morissard Ju00e9rome": "[email protected]"
    },
    "platforms": {
        "ios": "6.0"
    },
    "summary": "JMCache is a key/value store designed for persisting objects. NSCoding is not mandatory...",
    "license": {
        "type": "MIT"
    },
    "homepage": "https://github.com/leverdeterre/JMCache",
    "source": {
        "git": "https://github.com/leverdeterre/JMCache.git",
        "tag": "0.1"
    },
    "source_files": "JMCache/JMCache/JMCache/*"
}

Pin It on Pinterest

Share This