Data cache solution by Wu Xueying
Today, I think about a caching solution suitable for my project. I have basically tried it (I used CoreData all the time). 1. coredata: use MagicalRecord + Mogenerator to create a table and write a lot of parsing code. No need to resolve it. This is troublesome. serialization
[NSKeyedArchiver archiveRootObject: model toFile: path];
[NSKeyedUnarchiver unarchiveObjectWithFile: path];
Good and convenient, but I always feel that the experience is not good. After testing the method time, when the model size is large, the resolution time is basically more than MS, I gave up using 3. sqllite uses an open-source key-value Library recommended by Tang Qiao in the early stage, which is easy to use.
[[WTUtilsshared]. dbclearTable: @ "RestList"];
[[WTUtilsshared]. dbputObject: responsewithId: @ "restList" partition table: @ "RestList"];
Combined with today's Mantle
-(Void) loadSavedData {dispatch_async (dispatch_get_global_queue (0, 0), ^ {id data = [WTUtils shared]. db getObjectById: @ "restList" fromTable: @ "RestList"]; restListArray = [WTRestListEntity getRestListArray: data]; if (restListArray! = Nil) {DELAYEXECUTE (0.0, [_ tableView reloadData]);} else {[ZAActivityBar showWithStatus: @ "loading..."] ;}});}Finally, the cache effect is good, the code operation is simple, and the operability is good.
Data cache solution