GitHub API Cache provides cached result populated from GitHub API requests. As a default, GitHub only allows 60 API calls per hour for anonymous users. For authenticated users, GitHub only allows 5000 API calls per hour. Both are not enough for certain cases. As this stores responses populated from API requests into a web server's cache memory, it minimises the number of API calls so that API limit can be avoided.
Getting Started
GitHub API Cache supports three different authentication types – Anonymous, Basic and AuthenticationKey. Even though it supports the Basic authentication type, this is strongly NOT recommended to use as your GitHub username and password is exposed on the Internet.
Anonymouse Type
Let's say you are about to send a request to get a reference of a branch. If you use GitHub API, this is achieved by sending a request like:
TimeSpan: Duration for how long the cache value is alive, in seconds. Default value is 60.
UseAbsoluteUrl: If it is set to true, the cache key will use the fully qualified URL to store cache value. Default value is false.
UseQueryStringAsKey: If it is set to true, the cache key will use query string value corresponding to a specified key. Default value is false.
QueryStringKey: The key from query string to consider cache key. If UseQueryStringAsKey is false, this value is ignored.
CacheableStatusCodes: This is the list of HTTP status codes, delimited by comma, that allow to store into the cache. Default value is 200,304 that is equivalent to OK and Not Modified.
UseProxy: If your application sits behind a firewall, this value must be set to true; otherwise the application will not hit GitHub APIs. Default value is false.
ProxyUrl: Proxy server URL. This is necessary, if UseProxy value is true. If UseProxy valus is false, this is ignored.
BypassOnLocal: If it is set to true when UseProxy value is true, all local traffic is bypassed. If UseProxy value is false, this is ignored.
AuthenticationType: This determines how GitHub API is consumed. This value can be Anonymous, Basic and AuthenticationKey. Default value is Anonymous.
UseErrorLogEmail: If it is set to true, emails are sent to your designated email address on errors.
BypassHttps: If it is set to true, the RequireHttpsAttribute instance assumes the request is over HTTPS connection. Default value is false.
ApplicationServiceProviders: In case that additional check based on application service provider is required, this should be defined. Currently (version 1.5.0.0), this value can be either, Default or AppHarbor. Default value is nil.
SMTP settings above is the default. If you want to use your Gmail username and password, or similar web mail service to Gmail, you can simply change the settings like below:
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
请发表评论