-
Notifications
You must be signed in to change notification settings - Fork 55
Cache project list #150
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cache project list #150
Conversation
@jeff-phillips-18 Still WIP, but would be good to get your input. I'm working on the corresponding changes in origin-web-catalog and origin-web-console. |
src/services/projects.js
Outdated
Logger.debug("ProjectsService: listing projects, force refresh", forceRefresh); | ||
return DataService.list('projects', {}).then(function(projectData) { | ||
cachedProjectData = projectData; | ||
return projectData; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this watch for updates to the projects so that future calls get any updates that have occurred since the last retrieval?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think a global watch on projects will make the scale problem worse :(
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, so pages that expect to have the latest data would need to use the force flag then. Is there a plan to revisit the pages that are using this function to determine if the projects data could have changed and been the reason for the navigation? For instance, I add to a project and that takes me to another page. That page would expect a list call to return the latest data but it may not if no watcher was set and the force flag was not set.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's reasonable for changes outside of the web console to make the user refresh to get the latest list. We could instead re-list if the projects are fewer than a certain cutoff. But for extremely large lists or lists that fail, I don't see a good alternative. Trying to relist every page causes the console to become unusable.
For changes that happen in the web console, we can update the cached list directly. Let me make sure I'm doing that everywhere we can.
I'm looking at all the places we list or watch projects now, and I'm updating them to use the ProjectsService methods.
In 3.8, we'll be able to limit how many results we get back from the server, but not yet in 3.7.
src/services/projects.js
Outdated
// if we know the project list is large. | ||
return DataService.watch("projects", context, function(projectData) { | ||
cachedProjectData = projectData; | ||
callback(projectData); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A call to watch could return the current cachedProjectData. And invoke the callback again when projects change. This would be a bit more complex as this would need to handle unwatch as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good, I can make that change
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually I'm thinking it's better for callers to list first and then watch only if projects are less than some cutoff.
9b4b2cd
to
06cce9c
Compare
@jeff-phillips-18 Changed to keep the cached list updated on get/create/update/delete in console |
Cache the list of projects to avoid requesting them again and again on every page transition.
Cache the list of projects to avoid requesting them again and again on every page transition.
See openshift/origin-web-console#1923