Akavache is now open source
Today, we’re open-sourcing a library that we have been using at GitHub: Akavache. Akavache is an asynchronous, persistent key-value cache created for writing native desktop and mobile applications in C#.…
Today, we’re open-sourcing a library that we have been using at GitHub: Akavache.
Akavache is an asynchronous, persistent key-value cache created for writing native desktop and mobile applications in C#. Think of it like memcached for desktop apps.
What does that mean?
Downloading and caching remote data from the internet while still keeping the UI responsive is a task that nearly every modern native application needs to do. However, many applications that don’t take the consideration of caching into the design from the start often end up with inconsistent, duplicated code for caching different types of objects.
Akavache is a library that makes common app patterns easy, and unifies caching of different object types (i.e. HTTP responses vs. JSON objects vs. images).
It’s built on a core key-value byte array store (conceptually similar to a Dictionary<string, byte[]>
), and on top of that store, extensions are added to support:
- Arbitrary objects via JSON
- HTTP Requests
- Fetching and loading Images
- Securely storing User Credentials
An example – consider Twitter for Mac
When you open Twitter for Mac, you immediately see content, even before the application finishes talking to Twitter. This content is cached, but the pattern of when to refresh the data might be different. For the tweets themselves, the logic might be something like, “Load the cached data, but always fetch the latest data”.
However, for the avatar images, you might have logic like, “Always load the cached image, but if the avatar is older than six hours, refresh the image.”
In Akavache, the former might be:
var tweets = await BlobCache.UserAccount.GetAndFetchLatest("tweets", DownloadSomeTweets());
And the latter might be something like:
var image = await BlobCache.LocalMachine.GetAndFetchLatest(tweet.AvatarUrl,
DownloadUrl(tweet.AvatarUrl),
createdAt => DateTimeOffset.Now - createdAt > TimeSpan.FromHours(6));
No (Thread.)Sleep ’till Brooklyn
Akavache is non-blocking, via a library called the Reactive Extensions – any operation that could delay the UI returns an Observable, which represents a future result.
Akavache also solves several difficult concurrency problems that simplify UI programming. For example, in the image above, a naive cache implementation could end up loading the GitHub avatar icon multiple times if the requests were issued at the same time (which is easy to do if you try to load the avatar for each tweet). Akavache ensures that exactly one network request is issued.
Learn More
Check out the GitHub Repository for more examples, and install the package via NuGet. Akavache is also used extensively in Play for Windows, a desktop client for Play, your employee-powered office DJ.
Written by
Related posts

Explore the best of GitHub Universe: 9 spaces built to spark creativity, connection, and joy
See what’s happening at Universe 2025, from experimental dev tools and career coaching to community-powered spaces. Save $400 on your pass with Early Bird pricing.

Agents panel: Launch Copilot coding agent tasks anywhere on GitHub
Delegate coding tasks to Copilot and track progress wherever you are on GitHub. Copilot works in the background, creates a pull request, and tags you for review when finished.

Q1 2025 Innovation Graph update: Bar chart races, data visualization on the rise, and key research
Discover the latest trends and insights on public software development activity on GitHub with the quarterly release of data for the Innovation Graph, updated through March 2025.