Deprecated. In-memory cache, providing additional features like data filtering and serialization.
All members of SDMCache, including inherited members.
MethodsMember | Description |
---|---|
- (SDMODataServiceDocument *) getODataServiceDocument | Should retrieve the SDMODataServiceDocument. |
- (NSString *) getUid | Returns with the unique id of the cache. |
- (void) setODataServiceDocument: (SDMODataServiceDocument *) serviceDocument_in | Should set a valid metadata tree with a SDMODataServiceDocument as root, which will be kept in memory. |
- (void) setRegexSearchEnabled: (BOOL) flag_in | Enables in-cache filtering using regular expressions. |
Usage // 1. Initalize Cache SDMCache* cache = [SDMCache cacheWithServiceDoc:SvcDoc]; //the cache's UID is generated during the cache's initialization //set the cache that it will be persisted automatically if the application receives a memory warning from the system [SDMCache setShouldAutoSaveOnMemoryWarning:YES]; //the default value is NO, because if the user does not care about storing the uid and the library persists the cache, the user can not load the cache in without the uid //get the UID from the cache NSString* uid = [cache retrieveUID]; //store uid in UserDefaults to make it loadable in case of autoSaveOnMemoryWarning [[NSUserDefaults standardUserDefaults] setObject:uid forKey: UNIQUE_KEY_TO_STORE_AND_LOAD_THE_UID_OF_THE_CACHE ]; [[NSUserDefaults standardUserDefaults] synchronize]; // 2. Store Cache //get UID from cache object NSString* uid = [cache retrieveUID]; //store cache's uid in the UserDefaults for the UNIQUE_KEY_TO_STORE_AND_LOAD_THE_UID_OF_THE_CACHE [[NSUserDefaults standardUserDefaults] setObject:uid forKey: UNIQUE_KEY_TO_STORE_AND_LOAD_THE_UID_OF_THE_CACHE ]; [[NSUserDefaults standardUserDefaults] synchronize]; //store cache [[SDMPersistence instance] storeCache: cache]; //other (equivalent) solution //store the cache and get the uid of the cache NSString* uid = [[SDMPersistence instance] storeCache: cache]; //store cache's uid in the UserDefaults for the UNIQUE_KEY_TO_STORE_AND_LOAD_THE_UID_OF_THE_CACHE [[NSUserDefaults standardUserDefaults] setObject:uid forKey: UNIQUE_KEY_TO_STORE_AND_LOAD_THE_UID_OF_THE_CACHE ]; [[NSUserDefaults standardUserDefaults] synchronize]; // 3. Load Cache //load the previously persisted serviceDoc NSString* uid = (NSString*)[[NSUserDefaults standardUserDefaults] objectForKey: UNIQUE_KEY_TO_STORE_AND_LOAD_THE_UID_OF_THE_CACHE ]; #ifdef DEBUG NSLog("Cache's Uid: %", uid); #endif if ([NSString isNullOrEmpty: uid]) { //There is no UID saved for the UNIQUE_KEY_TO_STORE_AND_LOAD_THE_UID_OF_THE_CACHE }else{ //There is a UID saved for the UNIQUE_KEY_TO_STORE_AND_LOAD_THE_UID_OF_THE_CACHE //load the previosly persisted cache cache = [[SDMPersistence instance] loadCache:uid];