Skip to content

On Travis, serve Github update check requests from cache#1618

Merged
danielbachhuber merged 2 commits intomasterfrom
1612-cache-requests
Jan 21, 2015
Merged

On Travis, serve Github update check requests from cache#1618
danielbachhuber merged 2 commits intomasterfrom
1612-cache-requests

Conversation

@danielbachhuber
Copy link
Member

This will prevent us from hitting the API request rate-limiting.

When WP_CLI_REQUESTS_CACHE_DIR environment variable is set, check to
see if a cached version of the request is available from the static file
cache. If the cached version is available, serve it. If it's not
available, do the request and stash it in the cache.

Ideally, we'd be injecting our own Requests_Transport class, but
Requests doesn't easily support this.

See #1612

This will prevent us from hitting the API request rate-limiting.

When `WP_CLI_REQUESTS_CACHE_DIR` environment variable is set, check to
see if a cached version of the request is available from the static file
cache. If the cached version is available, serve it. If it's not
available, do the request and stash it in the cache.

Ideally, we'd be injecting our own `Requests_Transport` class, but
`Requests` doesn't easily support this.
@rmccue
Copy link
Contributor

rmccue commented Jan 20, 2015

Ideally, we'd be injecting our own Requests_Transport class, but

Would Requests::add_transport work for this? It's also possible to set Requests::$transport (an array) directly to override, but that's semi-internal behaviour. Happy to add extra methods if needed here.

@danielbachhuber
Copy link
Member Author

I looked at add_transport() but merging arrays adds my transport to the end of the stack. set_transport() would work, and built-in request cache would be even better. I need a solution in the near term though.

@rmccue
Copy link
Contributor

rmccue commented Jan 20, 2015

I looked at add_transport() but merging arrays adds my transport to the end of the stack. set_transport() would work, and built-in request cache would be even better. I need a solution in the near term though.

Sounds like we need a priority argument for the transports.

In this specific case, could you set $options['transport'] = new ... (or = 'ClassName', either way) directly? Looks like it's only this invocation that needs changing.

If this is run twice, we'll get a duplicate subdirectory. But, it
doesn't cause any problems
@danielbachhuber
Copy link
Member Author

I'm going with this PR to start, as this is an immediate problem we need to solve.

@danielbachhuber danielbachhuber added this to the next milestone Jan 21, 2015
danielbachhuber added a commit that referenced this pull request Jan 21, 2015
On Travis, serve Github update check requests from cache
@danielbachhuber danielbachhuber merged commit b28bde3 into master Jan 21, 2015
@danielbachhuber danielbachhuber deleted the 1612-cache-requests branch January 21, 2015 15:22
danielbachhuber added a commit that referenced this pull request Feb 13, 2015
This reverts commit b28bde3, reversing
changes made to aa15356.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants