Akavache.EncryptedSqlite3
12.0.8
Prefix Reserved
dotnet add package Akavache.EncryptedSqlite3 --version 12.0.8
NuGet\Install-Package Akavache.EncryptedSqlite3 -Version 12.0.8
<PackageReference Include="Akavache.EncryptedSqlite3" Version="12.0.8" />
<PackageVersion Include="Akavache.EncryptedSqlite3" Version="12.0.8" />
<PackageReference Include="Akavache.EncryptedSqlite3" />
paket add Akavache.EncryptedSqlite3 --version 12.0.8
#r "nuget: Akavache.EncryptedSqlite3, 12.0.8"
#:package Akavache.EncryptedSqlite3@12.0.8
#addin nuget:?package=Akavache.EncryptedSqlite3&version=12.0.8
#tool nuget:?package=Akavache.EncryptedSqlite3&version=12.0.8
<br>
<a href="https://www.nuget.org/packages/akavache.sqlite3">
<img src="https://img.shields.io/nuget/dt/akavache.sqlite3.svg">
</a>
<a href="#backers">
<img src="https://opencollective.com/reactiveui/backers/badge.svg">
</a>
<a href="#sponsors">
<img src="https://opencollective.com/reactiveui/sponsors/badge.svg">
</a>
<a href="https://reactiveui.net/slack">
<img src="https://img.shields.io/badge/chat-slack-blue.svg">
</a>
<img alt="Akavache" src="https://raw.githubusercontent.com/reactiveui/styleguide/master/logo_akavache/main.png" width="150" />
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 in V12
Akavache V12 rewrites the SQLite backend for direct SQLitePCLRaw 3.x access, replacing the sqlite-net-pcl ORM layer entirely. The result is lower per-operation allocations, dedicated worker-thread serialization of all native handle access, and commit coalescing for concurrent writes.
- SQLitePCLRaw direct access: Prepared statements cached and reused, parameters bound positionally — no ORM overhead
- SQLite3MultipleCiphers: Encrypted databases use SQLite3MC instead of sqlcipher
- Observable-first settings:
SettingsBaseproperties areIObservable<T>— no more.Wait()deadlocks - AOT-safe serialization:
JsonTypeInfo<T>overloads for System.Text.Json, trim-safe out of the box - System.Text.Json package split: Pure JSON package no longer pulls in Newtonsoft.Json
- Thread-safe disposal: All cache types use lock-free
Interlockedpatterns for idempotent dispose
See the Migration Guide: V11 to V12 for upgrade instructions.
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);
NuGet Packages
Install the packages that match your needs. At minimum you need the core package plus a storage backend and a serializer.
| Purpose | Package | NuGet |
|---|---|---|
| Core (in-memory cache) | Akavache | |
| SQLite persistence | Akavache.Sqlite3 | |
| Encrypted SQLite persistence | Akavache.EncryptedSqlite3 | |
| System.Text.Json serializer (recommended) | Akavache.SystemTextJson | |
| System.Text.Json BSON serializer | Akavache.SystemTextJson.Bson | |
| Newtonsoft.Json serializer | Akavache.NewtonsoftJson | |
| HTTP download and caching extensions | Akavache.HttpDownloader | |
| Image/bitmap caching | Akavache.Drawing | |
| Application settings helpers | Akavache.Settings | |
| V10 → V11 data migration | Akavache.V10toV11 |
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)
<PackageReference Include="Akavache.Sqlite3" Version="*" />
<PackageReference Include="Akavache.EncryptedSqlite3" Version="*" />
Serializers (Choose One - Required)
<PackageReference Include="Akavache.SystemTextJson" Version="*" />
<PackageReference Include="Akavache.NewtonsoftJson" Version="*" />
Optional Extensions
<PackageReference Include="Akavache.HttpDownloader" Version="*" />
<PackageReference Include="Akavache.Drawing" Version="*" />
<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 — properties are IObservable<T>
public class AppSettings : SettingsBase
{
public AppSettings() : base(nameof(AppSettings)) { }
public IObservable<bool> EnableNotifications => GetOrCreateObservable(true);
public IObservable<Unit> SetEnableNotifications(bool value) => SetObservable(value, nameof(EnableNotifications));
public IObservable<string> UserName => GetOrCreateObservable("DefaultUser");
public IObservable<Unit> SetUserName(string value) => SetObservable(value, nameof(UserName));
}
// 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 — subscribe for live updates or read once
await appSettings.SetUserName("John Doe");
await appSettings.SetEnableNotifications(false);
var name = await appSettings.UserName.FirstAsync();
Console.WriteLine($"User: {name}");
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: V10 → V11 - Upgrading from V10.x to V11.x
- Migration: V11 → V12 - Upgrading from V11.x to V12.x
- 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: SQLitePCLRaw and SQLite3MultipleCiphers - SQLite access and encryption 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
<a href="https://dotnetfoundation.org"> <img src="https://theme.dotnetfoundation.org/img/logo.svg" width="100" /> </a>
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.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net8.0-windows10.0.19041 is compatible. net9.0 is compatible. net9.0-android was computed. net9.0-android35.0 is compatible. net9.0-browser was computed. net9.0-ios was computed. net9.0-ios18.0 is compatible. net9.0-maccatalyst was computed. net9.0-maccatalyst18.0 is compatible. net9.0-macos was computed. net9.0-macos15.0 is compatible. net9.0-tvos was computed. net9.0-windows was computed. net9.0-windows10.0.19041 is compatible. net10.0 is compatible. net10.0-android was computed. net10.0-android36.0 is compatible. net10.0-browser was computed. net10.0-ios was computed. net10.0-ios26.0 is compatible. net10.0-maccatalyst was computed. net10.0-maccatalyst26.0 is compatible. net10.0-macos was computed. net10.0-macos26.0 is compatible. net10.0-tvos was computed. net10.0-windows was computed. net10.0-windows10.0.19041 is compatible. |
| .NET Framework | net462 is compatible. net463 was computed. net47 was computed. net471 was computed. net472 is compatible. net48 was computed. net481 is compatible. |
-
.NETFramework 4.6.2
- Akavache (>= 12.0.8)
- Microsoft.Bcl.AsyncInterfaces (>= 10.0.6)
- Splat.Builder (>= 19.3.1)
- SQLite3MC.PCLRaw.bundle (>= 2.3.3)
- SQLitePCLRaw.core (>= 3.0.2)
- System.Memory (>= 4.6.3)
- System.Reactive (>= 6.1.0)
-
.NETFramework 4.7.2
- Akavache (>= 12.0.8)
- Microsoft.Bcl.AsyncInterfaces (>= 10.0.6)
- Splat.Builder (>= 19.3.1)
- SQLite3MC.PCLRaw.bundle (>= 2.3.3)
- SQLitePCLRaw.core (>= 3.0.2)
- System.Memory (>= 4.6.3)
- System.Reactive (>= 6.1.0)
-
.NETFramework 4.8.1
- Akavache (>= 12.0.8)
- Microsoft.Bcl.AsyncInterfaces (>= 10.0.6)
- Splat.Builder (>= 19.3.1)
- SQLite3MC.PCLRaw.bundle (>= 2.3.3)
- SQLitePCLRaw.core (>= 3.0.2)
- System.Memory (>= 4.6.3)
- System.Reactive (>= 6.1.0)
-
net10.0
- Akavache (>= 12.0.8)
- Microsoft.Bcl.AsyncInterfaces (>= 10.0.6)
- Splat.Builder (>= 19.3.1)
- SQLite3MC.PCLRaw.bundle (>= 2.3.3)
- SQLitePCLRaw.core (>= 3.0.2)
- System.Reactive (>= 6.1.0)
-
net10.0-android36.0
- Akavache (>= 12.0.8)
- Microsoft.Bcl.AsyncInterfaces (>= 10.0.6)
- Splat.Builder (>= 19.3.1)
- SQLite3MC.PCLRaw.bundle (>= 2.3.3)
- SQLitePCLRaw.core (>= 3.0.2)
- System.Reactive (>= 6.1.0)
-
net10.0-ios26.0
- Akavache (>= 12.0.8)
- Microsoft.Bcl.AsyncInterfaces (>= 10.0.6)
- Splat.Builder (>= 19.3.1)
- SQLite3MC.PCLRaw.bundle (>= 2.3.3)
- SQLitePCLRaw.core (>= 3.0.2)
- System.Reactive (>= 6.1.0)
-
net10.0-maccatalyst26.0
- Akavache (>= 12.0.8)
- Microsoft.Bcl.AsyncInterfaces (>= 10.0.6)
- Splat.Builder (>= 19.3.1)
- SQLite3MC.PCLRaw.bundle (>= 2.3.3)
- SQLitePCLRaw.core (>= 3.0.2)
- System.Reactive (>= 6.1.0)
-
net10.0-macos26.0
- Akavache (>= 12.0.8)
- Microsoft.Bcl.AsyncInterfaces (>= 10.0.6)
- Splat.Builder (>= 19.3.1)
- SQLite3MC.PCLRaw.bundle (>= 2.3.3)
- SQLitePCLRaw.core (>= 3.0.2)
- System.Reactive (>= 6.1.0)
-
net10.0-windows10.0.19041
- Akavache (>= 12.0.8)
- Microsoft.Bcl.AsyncInterfaces (>= 10.0.6)
- Splat.Builder (>= 19.3.1)
- SQLite3MC.PCLRaw.bundle (>= 2.3.3)
- SQLitePCLRaw.core (>= 3.0.2)
- System.Reactive (>= 6.1.0)
-
net8.0
- Akavache (>= 12.0.8)
- Microsoft.Bcl.AsyncInterfaces (>= 10.0.6)
- Splat.Builder (>= 19.3.1)
- SQLite3MC.PCLRaw.bundle (>= 2.3.3)
- SQLitePCLRaw.core (>= 3.0.2)
- System.Reactive (>= 6.1.0)
-
net8.0-windows10.0.19041
- Akavache (>= 12.0.8)
- Microsoft.Bcl.AsyncInterfaces (>= 10.0.6)
- Splat.Builder (>= 19.3.1)
- SQLite3MC.PCLRaw.bundle (>= 2.3.3)
- SQLitePCLRaw.core (>= 3.0.2)
- System.Reactive (>= 6.1.0)
-
net9.0
- Akavache (>= 12.0.8)
- Microsoft.Bcl.AsyncInterfaces (>= 10.0.6)
- Splat.Builder (>= 19.3.1)
- SQLite3MC.PCLRaw.bundle (>= 2.3.3)
- SQLitePCLRaw.core (>= 3.0.2)
- System.Reactive (>= 6.1.0)
-
net9.0-android35.0
- Akavache (>= 12.0.8)
- Microsoft.Bcl.AsyncInterfaces (>= 10.0.6)
- Splat.Builder (>= 19.3.1)
- SQLite3MC.PCLRaw.bundle (>= 2.3.3)
- SQLitePCLRaw.core (>= 3.0.2)
- System.Reactive (>= 6.1.0)
-
net9.0-ios18.0
- Akavache (>= 12.0.8)
- Microsoft.Bcl.AsyncInterfaces (>= 10.0.6)
- Splat.Builder (>= 19.3.1)
- SQLite3MC.PCLRaw.bundle (>= 2.3.3)
- SQLitePCLRaw.core (>= 3.0.2)
- System.Reactive (>= 6.1.0)
-
net9.0-maccatalyst18.0
- Akavache (>= 12.0.8)
- Microsoft.Bcl.AsyncInterfaces (>= 10.0.6)
- Splat.Builder (>= 19.3.1)
- SQLite3MC.PCLRaw.bundle (>= 2.3.3)
- SQLitePCLRaw.core (>= 3.0.2)
- System.Reactive (>= 6.1.0)
-
net9.0-macos15.0
- Akavache (>= 12.0.8)
- Microsoft.Bcl.AsyncInterfaces (>= 10.0.6)
- Splat.Builder (>= 19.3.1)
- SQLite3MC.PCLRaw.bundle (>= 2.3.3)
- SQLitePCLRaw.core (>= 3.0.2)
- System.Reactive (>= 6.1.0)
-
net9.0-windows10.0.19041
- Akavache (>= 12.0.8)
- Microsoft.Bcl.AsyncInterfaces (>= 10.0.6)
- Splat.Builder (>= 19.3.1)
- SQLite3MC.PCLRaw.bundle (>= 2.3.3)
- SQLitePCLRaw.core (>= 3.0.2)
- System.Reactive (>= 6.1.0)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Akavache.EncryptedSqlite3:
| Package | Downloads |
|---|---|
|
Akavache.Settings
Package Description |
GitHub repositories
This package is not used by any popular GitHub repositories.