-1

What approach should I use to minimize disk i/o when reading/writing to SQLite database in Android? Something like ConcurrentHashMap with WeakReferences? Caffeine? GuavaCache?

Should I use built-in caches in ORMs like GreenDao, DBFlow, ORMLite? The documentation is very vague when it comes to clearing these caches... When should I clear them? Should I?

I tried to enable cache in ORMLite, but there were bugs: nulls instead of empty foreign collections after cascade delete/insert of entities...

So what's the best practice? Maybe not to use cache at all and just to read/write from DB asynchronously to ensure fresh data?

FelisManulus
  • 440
  • 4
  • 18

1 Answers1

0

You can wrap the reads to the database with a Lru cache in order to reduce the memory footprint (since it won't grow indefinetely). However, you will need to invalidate the records in case they are updated / removed from the storage.

Short video intro here.

fedepaol
  • 6,834
  • 3
  • 27
  • 34