Skip to content
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 the AccessToken for console session to speed up successive command requests #120

Merged
merged 1 commit into from
Jun 5, 2018

Conversation

HowardWolosky
Copy link
Member

Sped up the module for users not using a Proxy. AccessToken is now cached for the
duration of the console session, and only needs to be refreshed when it expires (which is about
every 60 minutes). Previously, the access token was only cached for the duration of the currently
executing command, which meant that any succesive interactions at the commandline required a new
AccessToken to be acquired.

CHANGELOG.md Outdated
## [1.16.4](https://github.com/Microsoft/StoreBroker/tree/1.16.4) - (2018/04/23)
### Fixes:

- Removed checks validation checks preventing some apps from updating
- Removed checks validation checks prevented some apps from updating
gaming options or trailers. The API now enables all apps to use
Copy link
Contributor

Choose a reason for hiding this comment

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

This sentence doesn't make much sense..

Copy link
Member Author

Choose a reason for hiding this comment

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

agreed. fixed.

$script:lastAccessToken = $null

# Indicates when $script:lastAccessToken has expired and must be refreshed
$script:lastAccessTokenExpirationDate = Get-Date
Copy link
Contributor

Choose a reason for hiding this comment

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

This works but [DateTime] 0 seems more like a $null equivalent.

Copy link
Member Author

Choose a reason for hiding this comment

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

Interesting. Wasn't aware of that. Will leave this as-is however, as the code seems more clear/obvious if i'm saying "it expires right now"


if ($PSCmdlet.ShouldProcess("", "Clear cached access token"))
{
$script:lastAccessToken = $null
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you need to reset $script:lastAccessTokenExpirationDate? Maybe this logic should move to a Clear-AccessToken function?

Copy link
Member Author

Choose a reason for hiding this comment

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

We only ever use the access token if it's non-null. Will consider this feedback however.

Copy link
Member Author

Choose a reason for hiding this comment

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

Decided to won't fix this.

…and requests

Sped up the module for users not using a Proxy.  `AccessToken` is now cached for the
duration of the console session, and only needs to be refreshed when it expires (which is about
every 60 minutes).  Previously, the access token was only cached for the duration of the currently
executing command, which meant that any succesive interactions at the commandline required a new
`AccessToken` to be acquired.
@HowardWolosky HowardWolosky merged commit 35a9538 into microsoft:master Jun 5, 2018
@HowardWolosky HowardWolosky deleted the cacheToken branch June 5, 2018 17:46
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