marcoarment / FCModel

An alternative to Core Data for people who like having direct SQL access.
MIT License
1.65k stars 173 forks source link

Add convenient method to clean all loaded (cached) instances #140

Open Kjuly opened 8 years ago

Kjuly commented 8 years ago

Hi @marcoarment ,

Like issue mentioned in https://github.com/marcoarment/FCModel/issues/106, when we cleaned several tables' records locally (execute sql statement directly) & try to pull data from server, these cached records will lead some problems.

e.g., we use updatedAt to judge whether need to update local record w/ the one fetched from server. As cached record will always have a same updatedAt to the one fetched from server, as a result, when cleaned local data & pull again from server, no new record will be created locally after pulling, cause we think these record exists & values are latest. Especially for the case that fetch big records one by one.

Though there's a way to load all cached instances w/ +allLoadedInstances and remove one by one w/ -removeFromCache, I think it's good to provide a convenient method to remove the whole cached array in g_instances at once. :)

Kjuly commented 8 years ago

Note: Updated the PR based on latest commit after merging Unique2 br.

Kjuly commented 8 years ago

Hi @marcoarment , plz take a review when u got time, and let me know if u've any concern about it, thx in advance.