0

Does anyone know how to disable ActiveAndroid default behavior of caching object models in LruCache?

I want to disable entirely from my project. I have been able to clear the cache manually using Cache.clear(); but I need to keep doing it every time I need to clear it. I just want to disable all together via configuration.

velval
  • 3,072
  • 36
  • 45

2 Answers2

0

You can use :

public final void evictAll ()

Clear the cache, calling entryRemoved(boolean, K, V, V) on each removed entry.

Deepak
  • 1
  • 1
  • Thanks @Deepak. But what I need is to disable caching altogether and not on a case by case manner. – velval Mar 01 '16 at 23:37
0

I couldn't find any documentation on this matter so I dug into the code and end up doing the below workaround.

It seems there is no way to disable caching in ActiveAndroid but they offer a way to set the maxSize of the LruCache via the Configuration class. So I initialized ActiveAndroid like this:

Configuration config = new Configuration.Builder(this).setCacheSize(1).create();
ActiveAndroid.initialize(config);

Setting the CacheSize to 1 sort of prevents the addition of Model objects to the cache so it seems to works fine.

velval
  • 3,072
  • 36
  • 45