Coder Social home page Coder Social logo

escache's Introduction

ESCache

ESCache is a simple NSCache/NSMutableDictionary (in secure version) wrapper which is backed by on-disk persistence. It has two useful classes: ESCache and ESSecureCache.

ESCache class might be used when you need to persist NSCache'd data to share it between launch sessions. ESSecureCache might be used to share data between sessions and it also encrypts persistent storage.

Example usage

ESCache

It's as simple as NSDictionary: you set and get objects. The only requirement is that these objects should conform to NSCoding protocol.

Cache the data
ESCache *cache = [[ESCache sharedCache] setObject:@"string to share" forKey:@"key"];
Retrieve the data
NSString *object = [[ESCache sharedCache] objectForKey:@"key"];

ESSecureCache

It has two possible ways to persist cached data: file-backed persistence and NSUserDefaults. File-backed persistence is used as 'default' in +sharedCache so use -initWithName:type:error: initializer to implicitly specify persistence type.

Create an ESSecureCache instance backed by NSUserDefaults persistence
// cache's name is used as a key for NSUserDefaults' -setObject:forKey:
// it would be used as a file name in case of file-backed persistence
_cache = [[ESSecureCache alloc] initWithName:@"ESSecureCache" type:ESSecureCacheTypeUserDefaults error:NULL]; 
Cache an object (it doesn't differ from ESCache's method)
[_cache setObject:@"string object" forKey:@"key"];
Retrieve the data
NSString *object = [_cache objectForKey:@"key"];

Requirements

ESCache requires iOS 4.3 and above or OS X 10.7 and above.

ARC

ESCache supports both ARC and non-ARC environment.

Contact

Drop me a line if you have questions regarding to that library.

License

ESCache is available under the MIT license. See the LICENSE file for more info.

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.