Akavache - akavache 6.2.3
An asynchronous, persistent key-value store for desktop and mobile applications on .NET
PM> Install-Package akavache -Version 6.2.3 -Source https://www.myget.org/F/Akavache/api/v3/index.json
> nuget.exe install akavache -Version 6.2.3 -Source https://www.myget.org/F/Akavache/api/v3/index.json
> dotnet add package akavache --version 6.2.3 --source https://www.myget.org/F/Akavache/api/v3/index.json
> choco install akavache --version 6.2.3 --source https://www.myget.org/F/Akavache/api/v2
Import-Module PowerShellGet
Register-PSRepository -Name "Akavache" -SourceLocation "https://www.myget.org/F/Akavache/api/v2"
Install-Module -Name "akavache" -RequiredVersion "6.2.3" -Repository "Akavache"
Copy to clipboard
Akavache: An Asynchronous Key-Value Store for Native Applications
Akavache is an asynchronous, persistent (i.e., writes to disk) key-value store created for writing desktop and mobile applications in C#, based on SQLite3. Akavache is great for both storing important data (i.e., user settings) as well as cached local data that expires.
What's New
Akavache V11.1 introduced a new Builder Pattern for initialization, improved serialization support, and enhanced cross-serializer compatibility:
- ๐๏ธ Builder Pattern: New fluent API for configuring cache instances
- ๐ Multiple Serializer Support: Choose between System.Text.Json, Newtonsoft.Json, each with a BSON variant
- ๐ Cross-Serializer Compatibility: Read data written by different serializers
- ๐งฉ Modular Design: Install only the packages you need
- ๐ฑ Enhanced .NET MAUI Support: First-class support for .NET 9 cross-platform development
- ๐ Improved Security: Better encrypted cache implementation
Development History
Akavache V11.1+ represents a significant evolution in the library's architecture, developed through extensive testing and community feedback in our incubator project. The new features and improvements in V11.1 were first prototyped and battle-tested in the ReactiveMarbles.CacheDatabase repository, which served as an experimental ground for exploring new caching concepts and architectural patterns.
Key Development Milestones:
- ๐งช Incubation Phase: The builder pattern, modular serialization system, and enhanced API were first developed and tested in ReactiveMarbles.CacheDatabase
- ๐ฌ Community Testing: Early adopters and contributors provided valuable feedback on the new architecture through real-world usage scenarios
- ๐ Production Validation: The incubator project allowed us to validate performance improvements, API ergonomics, and cross-platform compatibility before integrating into Akavache
- ๐ Iterative Refinement: Multiple iterations based on community feedback helped shape the final V11.1 API design and feature set
This careful incubation process ensured that V11.1 delivers not just new features, but a more robust, flexible, and maintainable caching solution that builds upon years of community experience and testing.
Quick Start
1. Install Packages
<PackageReference Include="Akavache.Sqlite3" Version="*" />
<PackageReference Include="Akavache.SystemTextJson" Version="*" />
2. Initialize Akavache
Note:
WithAkavache,WithAkavacheCacheDatabaseandInitializealways requires anISerializerdefined as a generic type, such asWithAkavache<SystemJsonSerializer>. This ensures the cache instance is properly configured for serialization.
Static Initialization (Recommended for most apps)
using Akavache.Core;
using Akavache.SystemTextJson;
using Akavache.Sqlite3;
using Splat.Builder;
// Initialize with the builder pattern
AppBuilder.CreateSplatBuilder()
.WithAkavacheCacheDatabase<SystemJsonSerializer>(builder =>
builder.WithApplicationName("MyApp")
.WithSqliteProvider() // REQUIRED: Explicitly initialize SQLite provider
.WithSqliteDefaults());
Important: Always call
WithSqliteProvider()explicitly beforeWithSqliteDefaults(). WhileWithSqliteDefaults()will automatically callWithSqliteProvider()if not already initialized (for backward compatibility), this automatic behavior is deprecated and may be removed in future versions. Explicit provider initialization is the recommended pattern for forward compatibility with other DI containers.
Dependency Injection Registration (for DI containers)
using Akavache.Core;
using Akavache.SystemTextJson;
using Akavache.Sqlite3;
using Splat.Builder;
// Example: Register Akavache with Splat DI
AppBuilder.CreateSplatBuilder()
.WithAkavache<SystemJsonSerializer>(
"MyApp",
builder => builder.WithSqliteProvider() // REQUIRED: Explicit provider initialization
.WithSqliteDefaults(),
(splat, instance) => splat.RegisterLazySingleton(() => instance));
// For in-memory cache (testing or lightweight scenarios):
AppBuilder.CreateSplatBuilder()
.WithAkavache<SystemJsonSerializer>(
"Akavache",
builder => builder.WithInMemoryDefaults(), // No provider needed for in-memory
(splat, instance) => splat.RegisterLazySingleton(() => instance));
3. Use the Cache
Basic Operations
// Store an object
var user = new User { Name = "John", Email = "john@example.com" };
await CacheDatabase.UserAccount.InsertObject("current_user", user);
// Retrieve an object
var cachedUser = await CacheDatabase.UserAccount.GetObject<User>("current_user");
// Store with expiration
await CacheDatabase.LocalMachine.InsertObject("temp_data", someData, DateTimeOffset.Now.AddHours(1));
// Get or fetch pattern
var data = await CacheDatabase.LocalMachine.GetOrFetchObject("api_data",
async () => await httpClient.GetFromJsonAsync<ApiResponse>("https://api.example.com/data"));
Cache Types
Akavache provides four types of caches:
- UserAccount: User settings and preferences that should persist and potentially sync
- LocalMachine: Cached data that can be safely deleted by the system
- Secure: Encrypted storage for sensitive data like credentials and API keys
- InMemory: Temporary storage that doesn't persist between app sessions
// User preferences (persistent)
await CacheDatabase.UserAccount.InsertObject("user_settings", settings);
// API cache (temporary)
await CacheDatabase.LocalMachine.InsertObject("api_cache", apiData, DateTimeOffset.Now.AddHours(6));
// Sensitive data (encrypted)
await CacheDatabase.Secure.SaveLogin("john.doe", "secretPassword", "myapp.com");
// Session data (in-memory only)
await CacheDatabase.InMemory.InsertObject("current_session", sessionData);
Installation
Akavache uses a modular package structure. Choose the packages that match your needs:
Core Package (In Memory only)
<PackageReference Include="Akavache" Version="*" />
Storage Backends (Choose One - Recommended)
<!-- SQLite persistence (most common) -->
<PackageReference Include="Akavache.Sqlite3" Version="*" />
<!-- Encrypted SQLite persistence -->
<PackageReference Include="Akavache.EncryptedSqlite3" Version="*" />
Serializers (Choose One - Required)
<!-- System.Text.Json (fastest, .NET native) -->
<PackageReference Include="Akavache.SystemTextJson" Version="*" />
<!-- Newtonsoft.Json (most compatible) -->
<PackageReference Include="Akavache.NewtonsoftJson" Version="*" />
Optional Extensions
<!-- Image/Bitmap support -->
<PackageReference Include="Akavache.Drawing" Version="*" />
<!-- Settings helpers -->
<PackageReference Include="Akavache.Settings" Version="*" />
Framework Support
Akavache supports:
- โ .NET Framework 4.6.2/4.7.2 - Windows desktop applications
- โ .NET Standard 2.0 - Cross-platform libraries
- โ .NET 8.0 - Modern .NET applications
- โ .NET 9.0 - Latest .NET applications
- โ .NET 10.0 - Latest .NET applications
- โ
Mobile Targets -
net9.0-android,net9.0-ios,net9.0-maccatalyst,net10.0-android,net10.0-ios,net10.0-maccatalyst - โ
Desktop Targets -
net9.0-windows10.0.19041.0,net10.0-windows10.0.19041.0(WinUI),net9.0,net10.0(cross-platform)
Serializer Compatibility
| Serializer | .NET Framework 4.6.2+ | .NET 8.0+ | Mobile | Performance |
|---|---|---|---|---|
| System.Text.Json | โ Via NuGet | โ | โ | Fastest |
| Newtonsoft.Json | โ Built-in | โ | โ | Compatible |
Recommendation: Use System.Text.Json for new projects for best performance. Use Newtonsoft.Json when migrating from older Akavache versions or when you need maximum compatibility.
Akavache.Settings: Configuration Made Easy
Akavache.Settings provides a specialized settings database for application configuration that survives app updates and reinstalls.
Quick Settings Example
using Akavache.Settings;
// 1. Create a settings class
public class AppSettings : SettingsBase
{
public AppSettings() : base(nameof(AppSettings)) { }
public bool EnableNotifications
{
get => GetOrCreate(true); // Default: true
set => SetOrCreate(value);
}
public string UserName
{
get => GetOrCreate("DefaultUser");
set => SetOrCreate(value);
}
public int MaxRetries
{
get => GetOrCreate(3);
set => SetOrCreate(value);
}
}
// 2. Initialize with your app
var appSettings = default(AppSettings);
AppBuilder.CreateSplatBuilder()
.WithAkavache<SystemJsonSerializer>(builder =>
builder.WithApplicationName("MyApp")
.WithSqliteProvider()
.WithSettingsStore<AppSettings>(settings => appSettings = settings));
// 3. Use the settings
appSettings.EnableNotifications = false;
appSettings.UserName = "John Doe";
appSettings.MaxRetries = 5;
Console.WriteLine($"User: {appSettings.UserName}");
Console.WriteLine($"Notifications: {appSettings.EnableNotifications}");
Settings are automatically persisted and will survive app updates, making them perfect for user preferences and application configuration.
Documentation
๐ Complete documentation is available in the /docs folder:
- Installation Guide - Detailed installation and package selection
- Configuration - Builder pattern, providers, and advanced setup
- Serializers - System.Text.Json vs Newtonsoft.Json comparison
- Cache Types - UserAccount, LocalMachine, Secure, and InMemory caches
- Basic Operations - CRUD operations and error handling
- Migration Guide - Upgrading from V10.x to V11.1
- Settings Management - Complete Akavache.Settings guide
- Platform Notes - Platform-specific guidance
- Performance - Benchmarks and optimization tips
- Best Practices - Recommended patterns and anti-patterns
- Troubleshooting - Common issues and solutions
Support and Contributing
- ๐ Documentation: https://github.com/reactiveui/Akavache
- ๐ Issues: GitHub Issues
- ๐ฌ Chat: ReactiveUI Slack
- ๐ฆ NuGet: Akavache Packages
Thanks
This project is tested with BrowserStack.
We want to thank the following contributors and libraries that help make Akavache possible:
Core Libraries
- SQLite: sqlite-net-pcl and SQLitePCLRaw - Essential SQLite support for .NET
- System.Reactive: Reactive Extensions for .NET - The foundation of Akavache's asynchronous API
- Splat: Splat - Cross-platform utilities and service location
- System.Text.Json: Microsoft's high-performance JSON serializer
- Newtonsoft.Json: James Newton-King's Json.NET - The most popular .NET JSON library
Microsoft
We thank Microsoft for their ongoing support of the .NET ecosystem and the development tools that make Akavache possible.
License
Akavache is licensed under the MIT License.
-
.NETFramework 4.6.1
- akavache.core (>= 6.2.3)
- akavache.sqlite3 (>= 6.2.3)
- SQLitePCLRaw.bundle_e_sqlite3 (>= 1.1.12)
-
MonoAndroid 8.0
- akavache.core (>= 6.2.3)
- akavache.sqlite3 (>= 6.2.3)
- SQLitePCLRaw.bundle_e_sqlite3 (>= 1.1.12)
-
Xamarin.iOS 1.0
- akavache.core (>= 6.2.3)
- akavache.sqlite3 (>= 6.2.3)
- SQLitePCLRaw.bundle_e_sqlite3 (>= 1.1.12)
-
Xamarin.Mac 2.0
- akavache.core (>= 6.2.3)
- akavache.sqlite3 (>= 6.2.3)
- SQLitePCLRaw.bundle_e_sqlite3 (>= 1.1.12)
-
.NETCoreApp 2.0
- akavache.core (>= 6.2.3)
- akavache.sqlite3 (>= 6.2.3)
- SQLitePCLRaw.bundle_e_sqlite3 (>= 1.1.12)
-
.NETStandard 2.0
- akavache.core (>= 6.2.3)
- akavache.sqlite3 (>= 6.2.3)
- SQLitePCLRaw.bundle_e_sqlite3 (>= 1.1.12)
-
UAP 10.0.16299
- akavache.core (>= 6.2.3)
- akavache.sqlite3 (>= 6.2.3)
- SQLitePCLRaw.bundle_e_sqlite3 (>= 1.1.12)
- .NETCoreApp 2.0: 2.0.0.0
- .NETFramework 4.6.1: 4.6.1.0
- .NETStandard 2.0: 2.0.0.0
- MonoAndroid 8.0: 8.0.0.0
- UAP 10.0.16299: 10.0.16299.0
- Xamarin.iOS 1.0: 1.0.0.0
- Xamarin.Mac 2.0: 2.0.0.0
Signature validation information
Informational
Signature Hash Algorithm: SHA256 Signature type: Author Verifying the author primary signature with certificate: Subject Name: CN=ReactiveUI (.NET Foundation), O=ReactiveUI (.NET Foundation), L=Redmond, S=Washington, C=US, SERIALNUMBER=603-389-068 SHA1 hash: C9D215757C98E4E57F2A0FC45537A405DC5F73A6 SHA256 hash: FD61A02C9A65214631F7F3720B7B05D66CE8EF77CFEF4D0FC357676E768C3758 Issued by: CN=.NET Foundation Projects Code Signing CA, O=.NET Foundation, C=US Valid from: 6/11/2018 12:00:00 AM to 6/15/2021 12:00:00 PM Timestamp: 12/27/2018 10:32:26 AM Verifying author primary signature's timestamp with timestamping service certificate: Subject Name: CN=DigiCert SHA2 Timestamp Responder, O=DigiCert, C=US SHA1 hash: 400191475C98891DEBA104AF47091B5EB6D4CBCB SHA256 hash: FC834D5BFFDE31DBA5B79BF95F573F7953BCBF9156E8525163E828EB92EA8A93 Issued by: CN=DigiCert SHA2 Assured ID Timestamping CA, OU=www.digicert.com, O=DigiCert Inc, C=US Valid from: 1/4/2017 12:00:00 AM to 1/18/2028 12:00:00 AM
Owners |
AuthorsPaul Betts |
Project URLhttps://github.com/akavache/Akavache |
LicenseMIT |
TagsAkavache Cache Xamarin Sqlite3 Magic |
SignatureValidation: Valid |
Info926 total downloads |
| 0 downloads for version 6.2.3 |
| Download (81.42 KB) |
| Found on the current feed only |
Package history
| Version | Size | Last updated | Downloads | Mirrored? | |||
|---|---|---|---|---|---|---|---|
|
|
6.3.2 | 82.02 KB | Fri, 01 Feb 2019 23:15:17 GMT | 0 |
|
||
|
|
6.3.1 | 82.01 KB | Fri, 25 Jan 2019 06:19:46 GMT | 0 |
|
||
|
|
6.2.7 | 82.06 KB | Fri, 25 Jan 2019 06:10:43 GMT | 0 |
|
||
|
|
6.2.3 | 81.42 KB | Thu, 27 Dec 2018 10:33:42 GMT | 0 |
|
||
|
|
6.2.2 | 81.45 KB | Thu, 27 Dec 2018 09:12:10 GMT | 0 |
|
||
|
|
6.2.1 | 81.4 KB | Thu, 27 Dec 2018 01:48:41 GMT | 0 |
|
||
|
|
6.1.8 | 81.41 KB | Thu, 27 Dec 2018 01:41:14 GMT | 1 |
|
||
|
|
6.1.7 | 81.39 KB | Thu, 27 Dec 2018 01:34:17 GMT | 1 |
|
||
|
|
6.1.6 | 81.36 KB | Thu, 27 Dec 2018 01:25:45 GMT | 0 |
|
||
|
|
6.1.5 | 81.4 KB | Thu, 27 Dec 2018 01:14:48 GMT | 0 |
|
||
|
|
6.1.4 | 81.35 KB | Thu, 27 Dec 2018 00:51:49 GMT | 0 |
|
||
|
|
6.1.3 | 81.42 KB | Mon, 24 Dec 2018 19:13:23 GMT | 1 |
|
||
|
|
6.1.2 | 81.43 KB | Mon, 24 Dec 2018 06:21:11 GMT | 0 |
|
||
|
|
6.1.1 | 81.39 KB | Sun, 23 Dec 2018 00:47:57 GMT | 1 |
|
||
|
|
6.0.36 | 81.37 KB | Sun, 23 Dec 2018 00:35:33 GMT | 2 |
|
||
|
|
6.0.35 | 81.43 KB | Sun, 23 Dec 2018 00:11:30 GMT | 0 |
|
||
|
|
6.0.34 | 81.36 KB | Sun, 23 Dec 2018 00:05:04 GMT | 1 |
|
||
|
|
6.0.33 | 11.16 KB | Sat, 22 Dec 2018 00:06:27 GMT | 1 |
|
||
|
|
6.0.31 | 11.15 KB | Thu, 08 Nov 2018 13:35:43 GMT | 2 |
|
||
|
|
6.0.30 | 11.15 KB | Tue, 16 Oct 2018 15:39:49 GMT | 1 |
|
||
|
|
6.0.27 | 11.16 KB | Mon, 01 Oct 2018 23:10:58 GMT | 2 |
|
||
|
|
6.0.24 | 11.16 KB | Sat, 15 Sep 2018 18:08:45 GMT | 1 |
|
||
|
|
6.0.23 | 11.16 KB | Sat, 15 Sep 2018 18:04:40 GMT | 4 |
|
||
|
|
6.0.22 | 11.16 KB | Thu, 13 Sep 2018 20:29:38 GMT | 7 |
|
||
|
|
6.0.20 | 11.16 KB | Wed, 05 Sep 2018 14:49:13 GMT | 1 |
|
||
|
|
6.0.19-beta | 11.17 KB | Wed, 29 Aug 2018 18:06:14 GMT | 0 |
|
||
|
|
6.0.18-beta | 11.17 KB | Wed, 29 Aug 2018 12:53:42 GMT | 0 |
|
||
|
|
6.0.17-beta | 11.16 KB | Fri, 24 Aug 2018 13:41:44 GMT | 3 |
|
||
|
|
6.0.0-alpha0038 | 2.12 KB | Sun, 03 Sep 2017 10:33:56 GMT | 40 |
|
||
|
|
5.1.0-alpha0037 | 2.12 KB | Sun, 03 Sep 2017 09:51:53 GMT | 7 |
|
||
|
|
5.1.0-alpha0036 | 2.13 KB | Sun, 03 Sep 2017 09:27:46 GMT | 2 |
|
||
|
|
5.1.0-alpha0035 | 2.12 KB | Fri, 25 Aug 2017 20:53:10 GMT | 14 |
|
||
|
|
5.1.0-alpha0008 | 2.72 KB | Sat, 20 May 2017 10:31:20 GMT | 24 |
|
||
|
|
5.1.0-alpha0005 | 2.71 KB | Wed, 05 Apr 2017 21:33:37 GMT | 1 |
|
||
|
|
5.1.0-alpha0004 | 2.72 KB | Mon, 23 Jan 2017 09:26:57 GMT | 6 |
|
||
|
|
5.1.0-alpha0003 | 2.71 KB | Mon, 16 Jan 2017 19:54:10 GMT | 0 |
|
||
|
|
5.1.0-alpha0002 | 2.69 KB | Fri, 04 Nov 2016 16:17:56 GMT | 12 |
|
||
|
|
5.0.1-ghuntley-patch--0001 | 2.7 KB | Fri, 04 Nov 2016 16:09:10 GMT | 3 |
|
||
|
|
5.0.0.1478269438 | 3.05 KB | Fri, 04 Nov 2016 14:25:28 GMT | 543 |
|
||
|
|
5.0.0.1477562522 | 3.05 KB | Thu, 27 Oct 2016 10:03:30 GMT | 65 |
|
||
|
|
5.0.0.1476383622 | 3.05 KB | Thu, 13 Oct 2016 18:35:07 GMT | 80 |
|
||
|
|
5.0.0 | 2.67 KB | Fri, 04 Nov 2016 15:08:05 GMT | 38 |
|
||
|
|
4.2.0-alpha0075 | 2.69 KB | Fri, 04 Nov 2016 14:43:58 GMT | 1 |
|
||
|
|
4.1.3-beta0001 | 2.69 KB | Fri, 04 Nov 2016 14:35:52 GMT | 61 |
|