Search code examples
androidrobospice

Rationale behind loading all cache data in RoboSpice's Persistor?


Writing a custom Persistor for saving a certain types of data object , one needs to extend ObjectPersistor of Robospice.

What is the reason behind these two methods required to implement?

@Override
public List<T> loadAllDataFromCache() throws CacheLoadingException {

}

@Override
public List<Object> getAllCacheKeys() {

}

A disk cache or any undelying Object store, can be HUGE. Why RoboSpice wants to load all data in memory ?


Solution

  • If you follow the call hierarchy, you will find that loadAllDataFromCache() is indirectly used only by com.octo.android.robospice.SpiceManager#getAllDataFromCache. For getAllCacheKeys(), it is similar - there is com.octo.android.robospice.SpiceManager#getAllCacheKeys utilizing it.

    This means that you will probably be well off by implementing these methods to just throw an UnsupportedOperationException. You should also consider overriding SpiceManager's methods by the same logic.