Could I ask how DB cache (assue as Key Vaule store) know if there is data missing for query?
If the DB query like select * from job where time < Now and time > now - 5 mins, for example, there are 1K output from above query. How does cache know all 1K data is avaivle in cache or not, to determine if cache need to check DB for missing data ?
The above question could be help to clarify if the followin use case could be optimized with one time query with long interval .
For exmaple, we need to query the DB every second for job scheduled in DB to get the last second job
select * from job where time < Now and time > now - 1 second
With the regular way, it could have data missing for above query, and we may need to query DB each time?
If we issue the query to check DB for every 5 mins, and set the expiraion policy over 5 mins, would it be ensure all queried data in 5 mins in cache, and decrease the cache missing rate for every second query?
In that case, it help to improve the performance for cache
select * from job where time < Now and time > now - 5 MIN