Tested the changes by making invalidation happen by :
Setting cache timeout (KEY_DATA_CACHE_EXPIRY_AFTER_WRITE) to a K second and firing long-running query. Invalidation happens at regular interval and the query does not fail. (generation number increases)
Setting the size of the cache (KEY_MAX_CACHE_SIZE) to K MB and firing the query to scan data more than K MB from 2-3 tables. In this case, also invalidation happens and verified queries do not fail.
Manually deleting the cache directory while a query was running, verified query does not fail and generation number increases.
grepped the log directory to check any errors too.
setAllCached api also needs to be made generationNumber aware because it is possible that it is called after caching data for old gen data file which will cause corruption as currently you are updating the cache status.
We need a test that runs CachedReads in parallel to invalidations being forced
Tested the changes by making invalidation happen by :