Table of Contents

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.

public static class CacheDatabase
Inheritance
CacheDatabase

Properties

ApplicationName

Gets the application name used for cache file paths.

public static string? ApplicationName { get; }

Property Value

string

ForcedDateTimeKind

Gets the forced DateTime kind for DateTime serialization. When set, all DateTime values will be converted to this kind during cache operations.

public static DateTimeKind? ForcedDateTimeKind { get; }

Property Value

DateTimeKind?

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.

public static IBlobCache InMemory { get; }

Property Value

IBlobCache

IsInitialized

Gets a value indicating whether CacheDatabase has been initialized.

public static bool IsInitialized { get; }

Property Value

bool

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.

public static IBlobCache LocalMachine { get; }

Property Value

IBlobCache

Secure

Gets the Secure cache instance. This cache provides encrypted storage for sensitive data like credentials and API keys.

public static ISecureBlobCache Secure { get; }

Property Value

ISecureBlobCache

TaskpoolScheduler

Gets or sets the Scheduler used for task pools.

public static IScheduler TaskpoolScheduler { get; set; }

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.

public static IBlobCache UserAccount { get; }

Property Value

IBlobCache

Methods

CreateBuilder(FileLocationOption)

Creates a new Akavache builder for configuration.

public static IAkavacheBuilder CreateBuilder(FileLocationOption fileLocationOption = FileLocationOption.Default)

Parameters

fileLocationOption FileLocationOption

The file location option.

Returns

IAkavacheBuilder

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

configure Action<IAkavacheBuilder>

An action to configure the Akavache builder.

applicationName string

Name of the application.

fileLocationOption FileLocationOption

The file location option.

Type Parameters

T

The 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

configureSerializer Func<T>

The Serializer configuration.

configure Action<IAkavacheBuilder>

An action to configure the Akavache builder.

applicationName string

Name of the application.

fileLocationOption FileLocationOption

The file location option.

Type Parameters

T

The 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

configureSerializer Func<T>

The Serializer configuration.

applicationName string

The application name for cache directories. If null, uses the current ApplicationName.

fileLocationOption FileLocationOption

The file location option.

Type Parameters

T

The 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

applicationName string

The application name for cache directories. If null, uses the current ApplicationName.

fileLocationOption FileLocationOption

The file location option.

Type Parameters

T

The serializer.

Exceptions

InvalidOperationException

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.

public static IObservable<Unit> Shutdown()

Returns

IObservable<Unit>

An observable that completes when shutdown is finished.