Skip to content
This repository was archived by the owner on Dec 5, 2024. It is now read-only.

Conversation

@StanleyGoldman
Copy link
Contributor

@StanleyGoldman StanleyGoldman commented Nov 9, 2017

Fixes: #412

Problems:

  1. user data is not cached and queried for on demand
  2. the object User has been used as a data object from GitClient

Solutions:

  1. Introduce GitUser as the data object from GitClient
  2. Use User much like Repository as the central front end to user data and actions
    1. User gets initialized with a GitClient and initiates a process to update it's data
    2. User listens to invalidation events from the GitUserCache and updates it's data
  3. Remove vestiges of User and user data from Repository and RepositoryManager
  4. Updating functionality in UserSettingsView and InitProviewView to use the new cache

Depends on:

@StanleyGoldman StanleyGoldman force-pushed the enhancements/git-client-cache branch from 08499a5 to 2d0b24b Compare November 9, 2017 17:56
@StanleyGoldman StanleyGoldman force-pushed the enhancements/git-client-cache branch from 6488f60 to bf459e2 Compare November 13, 2017 22:38
@grokys
Copy link

grokys commented Nov 14, 2017

Just to clarify as it's not clear from the title/description: this PR should only be caching user data?

@StanleyGoldman
Copy link
Contributor Author

The title of this PR could be clearer, but yes, I added access to cache objects to GitClient, so that GitClient could cache and manager user data.

@StanleyGoldman
Copy link
Contributor Author

I updated the description.

@StanleyGoldman StanleyGoldman mentioned this pull request Nov 14, 2017
7 tasks
Misunderstood the initial requirements. I believed the User object was
just for currying data. So I created GitUser to represent the user data
returned from GitClient and then moved the caching functionality over to
User.
More rippling changes from the previous implementation attempt
Moving the functionality to set the name an email to User and changing
UserSettingsView to use that method.

Also did some minor method renames.
@StanleyGoldman StanleyGoldman changed the title Adding a cache to GitClient Utilizing the GitUserCache Nov 21, 2017
@StanleyGoldman StanleyGoldman changed the title Utilizing the GitUserCache Utilizing a cache for user data Nov 21, 2017
The new method name is clearer as to what the method is checking for
Copy link

@grokys grokys left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got one question about event handlers preventing GC. Note this this also applies to Repository.

this.cacheContainer = cacheContainer;

cacheContainer.GitUserCache.CacheInvalidated += GitUserCacheOnCacheInvalidated;
cacheContainer.GitUserCache.CacheUpdated += GitUserCacheOnCacheUpdated;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will the User objects never need to be GCd? Adding these event handlers will mean that cacheContainer.GitUserCache will retain a reference to each User object.

Copy link
Contributor Author

@StanleyGoldman StanleyGoldman Nov 21, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

User and Repository are found on DefaultEnvironment.

IUser User { get; set; }
IRepository Repository { get; set; }

public IRepository Repository { get; set; }
public IUser User { get; set; }

There is generally only one instance of User and Repository in the system created at specific points of initialization.

User = new User(CacheContainer);

Repository = new Repository(RepositoryPath, CacheContainer);

These objects are only "destroyed" when the domain reloads.

When they are constructed (either the first time or after a domain reload) these objects are being fed a CacheContainer. It will take a moment on some other threads for the User and Repository objects to get what they need to be fully functioning (they both have Initialize methods for that).

These objects store their data in file based caches specifically for this reason. Until they are fully functioning, they get to use their file based cache to supply data to the user interface.

@drguthals
Copy link

This looks good to me @StanleyGoldman - Just take a look at @grokys question above

Copy link

@grokys grokys left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@StanleyGoldman StanleyGoldman merged commit 61771b0 into master Nov 22, 2017
@StanleyGoldman StanleyGoldman deleted the enhancements/git-client-cache branch November 22, 2017 15:01
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants