Skip to content

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

Merged
merged 1 commit into from
Aug 22, 2017
Merged

Cache project list #150

merged 1 commit into from
Aug 22, 2017

Conversation

spadgett
Copy link
Member

@spadgett spadgett commented Aug 21, 2017

Cache the list of projects to avoid requesting them again and again on every page transition.

See openshift/origin-web-console#1923

@spadgett
Copy link
Member Author

@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.

Logger.debug("ProjectsService: listing projects, force refresh", forceRefresh);
return DataService.list('projects', {}).then(function(projectData) {
cachedProjectData = projectData;
return projectData;
Copy link
Member

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?

Copy link
Member Author

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 :(

Copy link
Member

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.

Copy link
Member Author

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.

// if we know the project list is large.
return DataService.watch("projects", context, function(projectData) {
cachedProjectData = projectData;
callback(projectData);
Copy link
Member

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.

Copy link
Member Author

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

Copy link
Member Author

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.

@spadgett spadgett force-pushed the project-list branch 3 times, most recently from 9b4b2cd to 06cce9c Compare August 21, 2017 17:43
@spadgett
Copy link
Member Author

@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.
@spadgett spadgett changed the title [WIP] Cache project list Cache project list Aug 22, 2017
@spadgett spadgett merged commit 1cd15dd into openshift:master Aug 22, 2017
@spadgett spadgett deleted the project-list branch August 22, 2017 19:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants