nigel-sampson / octokit.caching

Caching Http Backend for Octokit
Apache License 2.0
8 stars 4 forks source link

Octokit.Caching

A decorator for Octokit.NET's IHttpClient that adds support for the caching of results and respecting etags.

Usage

There is an overload of the GitHubClient constructor that takes an IConnection. We use this to create a Connection where we inject our custom http client.

var connection = new Connection(
    new ProductHeaderValue("Ocotokit.Caching.Tests", "1.0.0"),
    GitHubClient.GitHubApiUrl,
    new InMemoryCredentialStore(new Credentials("token")),
    new CachingHttpClient(new HttpClientAdapter(), new NaiveInMemoryCache()),
    new SimpleJsonSerializer());

var client = new GitHubClient(connection);

CachingHttpClient takes an instance of ICache so you can injection your own custom caching behaviour.