Class CacheDatabase
- Namespace
- Akavache
- Assembly
- Akavache.dll
CacheDatabase is the main entry point for interacting with Akavache. It provides convenient static properties for accessing common cache locations. This V11 implementation uses a builder pattern for configuration.
- Inheritance
-
Cache
Database
Properties
ApplicationName
Gets the application name used for cache file paths.
Property Value
ForcedDateTimeKind
Gets the forced DateTime kind for DateTime serialization. When set, all DateTime values will be converted to this kind during cache operations.
Property Value
InMemory
Gets the InMemory cache instance. This cache stores data only in memory and is lost when the application shuts down. Useful for temporary data and session state.
Property Value
IsInitialized
Gets a value indicating whether CacheDatabase has been initialized.
Property Value
LocalMachine
Gets the LocalMachine cache instance. This cache persists data but is suitable for temporary/cached data that can be safely deleted. On mobile platforms, the system may delete this data to free up disk space.
Property Value
Secure
Gets the Secure cache instance. This cache provides encrypted storage for sensitive data like credentials and API keys.
Property Value
TaskpoolScheduler
Gets or sets the Scheduler used for task pools.
Property Value
- IScheduler
UserAccount
Gets the UserAccount cache instance. This cache persists data and is suitable for storing user settings and preferences that should survive app restarts. On some platforms, this data may be backed up to the cloud.
Property Value
Methods
CreateBuilder(FileLocationOption)
Creates a new Akavache builder for configuration.
public static IAkavacheBuilder CreateBuilder(FileLocationOption fileLocationOption = FileLocationOption.Default)
Parameters
fileLocationOptionFileLocation Option The file location option.
Returns
- IAkavache
Builder A new Akavache builder instance.
Initialize<T>(Action<IAkavacheBuilder>, string?, FileLocationOption)
Initializes CacheDatabase with a custom builder configuration.
[RequiresUnreferencedCode("Serializers require types to be preserved for serialization.")]
public static void Initialize<T>(Action<IAkavacheBuilder> configure, string? applicationName = null, FileLocationOption fileLocationOption = FileLocationOption.Default) where T : ISerializer, new()
Parameters
configureAction<IAkavacheBuilder >An action to configure the Akavache builder.
applicationNamestringName of the application.
fileLocationOptionFileLocation Option The file location option.
Type Parameters
TThe serializer.
Initialize<T>(Func<T>, Action<IAkavacheBuilder>, string?, FileLocationOption)
Initializes CacheDatabase with a custom builder configuration.
[RequiresUnreferencedCode("Serializers require types to be preserved for serialization.")]
public static void Initialize<T>(Func<T> configureSerializer, Action<IAkavacheBuilder> configure, string? applicationName = null, FileLocationOption fileLocationOption = FileLocationOption.Default) where T : ISerializer, new()
Parameters
configureSerializerFunc<T>The Serializer configuration.
configureAction<IAkavacheBuilder >An action to configure the Akavache builder.
applicationNamestringName of the application.
fileLocationOptionFileLocation Option The file location option.
Type Parameters
TThe serializer.
Initialize<T>(Func<T>, string?, FileLocationOption)
Initializes CacheDatabase with default in-memory caches. This is the safest default as it doesn't require any additional packages.
[RequiresUnreferencedCode("Serializers require types to be preserved for serialization.")]
public static void Initialize<T>(Func<T> configureSerializer, string? applicationName = null, FileLocationOption fileLocationOption = FileLocationOption.Default) where T : ISerializer, new()
Parameters
configureSerializerFunc<T>The Serializer configuration.
applicationNamestringThe application name for cache directories. If null, uses the current ApplicationName.
fileLocationOptionFileLocation Option The file location option.
Type Parameters
TThe serializer.
Initialize<T>(string?, FileLocationOption)
Initializes CacheDatabase with default in-memory caches. This is the safest default as it doesn't require any additional packages.
[RequiresUnreferencedCode("Serializers require types to be preserved for serialization.")]
public static void Initialize<T>(string? applicationName = null, FileLocationOption fileLocationOption = FileLocationOption.Default) where T : ISerializer, new()
Parameters
applicationNamestringThe application name for cache directories. If null, uses the current ApplicationName.
fileLocationOptionFileLocation Option The file location option.
Type Parameters
TThe serializer.
Exceptions
- Invalid
Operation Exception Failed to create AkavacheBuilder instance.
Shutdown()
Shuts down all cache instances and flushes any pending operations. This should be called before the application terminates to ensure all data is properly saved.
Returns
- IObservable<Unit>
An observable that completes when shutdown is finished.