The Cache layer allows us to abstract the local source of data that our application uses. In this lesson, we're going to be creating the Projects Cache data source within the cache layer to allow us to provide cached data to parts of the project requesting it.
I'm getting an error on the isProjectsCacheExpired function. Android Studio does not recognize the single() method. I've looked over my library refererences and I'm using all of the same version numbers as you are. I am using a newer version of Android Studio 3.2 Beta 5, but not sure that would cause the problem. Intellisense is trying to get me to use toSingle() which seems to work. Can you tell me what library is providing the single method? Perhaps it's been replaced by toSingle().
Also I'm confused by your 60 * 10 * 1000 code. What is this supposed to be determining? There are 86400000 milliseconds in a day.
and on the milliseconds, that is correct - it is just a representation of time. We state here that the cache is expired after a day!
I found the problem. When creating the configDao class, I entered the code as shown in the video which omitted a code change you made later. In the video you typed:
abstract fun getConfig(): Config
But the actual code was:
abstract fun getConfig(): Flowable
Once I fixed this the single method worked.
There is an error in code on video.
We are calling projectsDatabase.cachedProjctsDao().getBookMarkedProjects() in getProjects() instead of projectsDatabase.cachedProjctsDao().getProjects()
Isn’t this class violating SRP? It is responsible i.a. for two pieces of logic: determining if project are cached and determining if cache has expired.