Skip to content

A Cache Library with flexible storage options and policies

Notifications You must be signed in to change notification settings

leonylcatwork/MMCache

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 

Repository files navigation

MMCache

A Cache Library with flexible storage options and policies

This is a practice project for beginner.

Install

Copy /scr folder to your project and import "MMCache.h".

Usage

  1. Custom object must conform to NSCoding. Extend your existing class with category and adapt NSCoding.
  2. Instantiate MMCache instance (singleton sharedCache is available).
  3. Configure cache policy (LRU, LFU, FIFO, etc.), storage type (in memory or persistent), and cache capacity (in terms of number of cached items)
  4. Add/remove/achieve object using provided methods.

Example

MMCache.sharedCache.policyType = MMCPolicyTypeLRU;
MMCache.sharedCache.storageType = MMCStorageTypeInMemory;
MMCache.sharedCache.capacity = 100;

NSArray <NSString *> *names = @[@"Ana, Elsa, Lisa, Christ"];
[MMCache.sharedCache saveObject:names level:MMCLevelHigh];

NSDictionary <NSString *, NSNumber *> *kids = @{@"Alex" : @5, @"Phil" : @2, @"Mark" : @10};
[MMCache.sharedCache saveObject:kids level:MMCLevelLow];

To do

  1. Persistent type of storage is not implemented yet. This class must conforms to protocol 'MMCStorable'.
  2. Dynamically setting capacity should trim cache size to desired value using given policy.
  3. Storage should provide more flexible query methods other than what is defined in 'MMCStorable'.

About

A Cache Library with flexible storage options and policies

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages