Giter VIP home page Giter VIP logo

jmcache's Introduction

JMCache

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;

jmcache's People

Contributors

leverdeterre avatar

Watchers

Carabineiro avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.