Table of Contents

Interface IAkavacheConnection

Namespace
Akavache
Assembly
Akavache.dll

Abstracts the database connection used by SQLite-backed blob caches. The surface is intentionally narrow and CacheEntry-specific so that implementations can bind parameters and cache prepared statements without going through reflection or an expression-tree translator.

public interface IAkavacheConnection : IDisposable
Inherited Members
Extension Methods

Remarks

Every method returns IObservable<T> rather than Task — this matches the observable-first shape of IBlobCache so the whole sqlite pipeline composes directly with Rx operators without Task/await bridges. Cancellation is expressed through subscription disposal: unsubscribing before an operation completes is the observable-native "cancel" signal. Note that operations already dequeued by the worker thread cannot be cancelled mid-sqlite3_step — SQLite has no per-statement cancel primitive.

Single-value reads (Get(string, string?, DateTimeOffset), TryReadLegacyV10Value(string, DateTimeOffset, Type?), TableExists(string)) emit exactly one value and then complete. Multi-value reads (GetMany(IReadOnlyList<string>, string?, DateTimeOffset), GetAll(string?, DateTimeOffset), GetAllKeys(string?, DateTimeOffset)) emit one item per matching row and then complete; callers that want a materialized list can apply .ToList() at the boundary. Writers (Upsert(IReadOnlyList<CacheEntry>), Invalidate(IReadOnlyList<string>, string?), SetExpiry(string, string?, DateTimeOffset?), etc.) emit a single System.Reactive.Unit and then complete on success or OnError on failure.

Task-returning adapters live on IAkavacheConnectionTaskExtensions for callers that prefer async/await at the boundary — those are thin ToTask<TResult>(IObservable<TResult>) wrappers that do not take part in the hot path.

Methods

Checkpoint(CheckpointMode)

Requests a WAL checkpoint at the specified strength. Backends with no write-ahead log should treat this as a no-op and emit System.Reactive.Unit immediately.

IObservable<Unit> Checkpoint(CheckpointMode mode)

Parameters

mode CheckpointMode

The checkpoint strength.

Returns

IObservable<Unit>

A one-shot observable that fires when the checkpoint finishes.

Compact()

Requests that the backend reclaim unused storage. On SQLite this maps to VACUUM. Emits a single System.Reactive.Unit on completion.

IObservable<Unit> Compact()

Returns

IObservable<Unit>

A one-shot observable that fires when compaction finishes.

CreateSchema()

Creates the CacheEntry table (and supporting indexes) if it does not already exist. Emits a single System.Reactive.Unit when the schema is ready.

IObservable<Unit> CreateSchema()

Returns

IObservable<Unit>

A one-shot observable that signals schema creation completion.

Get(string, string?, DateTimeOffset)

Reads a single cache entry by key, honouring expiration and an optional type filter. Emits exactly one value: the entry, or null when no matching row exists (or the row is expired).

IObservable<CacheEntry?> Get(string key, string? typeFullName, DateTimeOffset now)

Parameters

key string

The cache key.

typeFullName string

Optional type discriminator. null matches rows regardless of type.

now DateTimeOffset

The wall-clock instant used to filter expired rows.

Returns

IObservable<CacheEntry>

A one-shot observable that emits the matching entry or null.

GetAll(string?, DateTimeOffset)

Reads every unexpired cache entry in the store, optionally filtered by type. Emits one item per row, then completes.

IObservable<CacheEntry> GetAll(string? typeFullName, DateTimeOffset now)

Parameters

typeFullName string

Optional type discriminator.

now DateTimeOffset

The wall-clock instant used to filter expired rows.

Returns

IObservable<CacheEntry>

An observable sequence of matching entries.

GetAllKeys(string?, DateTimeOffset)

Reads every unexpired cache entry key, optionally filtered by type. Emits one item per key, then completes.

IObservable<string> GetAllKeys(string? typeFullName, DateTimeOffset now)

Parameters

typeFullName string

Optional type discriminator.

now DateTimeOffset

The wall-clock instant used to filter expired rows.

Returns

IObservable<string>

An observable sequence of matching keys.

GetMany(IReadOnlyList<string>, string?, DateTimeOffset)

Reads every unexpired cache entry whose key is in keys. Emits one item per matching row, in no particular order, then completes.

IObservable<CacheEntry> GetMany(IReadOnlyList<string> keys, string? typeFullName, DateTimeOffset now)

Parameters

keys IReadOnlyList<string>

Keys to look up.

typeFullName string

Optional type discriminator.

now DateTimeOffset

The wall-clock instant used to filter expired rows.

Returns

IObservable<CacheEntry>

An observable sequence of matching entries.

Invalidate(IReadOnlyList<string>, string?)

Deletes cache entries by key within a single transaction. If a type discriminator is supplied, only rows whose TypeName matches are removed. Emits a single System.Reactive.Unit on commit.

IObservable<Unit> Invalidate(IReadOnlyList<string> keys, string? typeFullName)

Parameters

keys IReadOnlyList<string>

Keys to remove.

typeFullName string

Optional type discriminator.

Returns

IObservable<Unit>

A one-shot observable that fires on commit.

InvalidateAll(string?)

Removes every row from the CacheEntry table, optionally filtered by type. Emits a single System.Reactive.Unit on commit.

IObservable<Unit> InvalidateAll(string? typeFullName)

Parameters

typeFullName string

Optional type discriminator. null wipes everything.

Returns

IObservable<Unit>

A one-shot observable that fires on commit.

SetExpiry(string, string?, DateTimeOffset?)

Updates the expiration time of a cache entry by key, with an optional type filter. Emits a single System.Reactive.Unit on commit.

IObservable<Unit> SetExpiry(string key, string? typeFullName, DateTimeOffset? expiresAt)

Parameters

key string

The cache key.

typeFullName string

Optional type discriminator.

expiresAt DateTimeOffset?

The new expiration instant, or null to clear.

Returns

IObservable<Unit>

A one-shot observable that fires on commit.

TableExists(string)

Checks whether a table with the specified name exists in the database. Emits a single bool.

IObservable<bool> TableExists(string tableName)

Parameters

tableName string

The table name.

Returns

IObservable<bool>

A one-shot observable that emits true when the table exists, false otherwise.

TryReadLegacyV10Value(string, DateTimeOffset, Type?)

Attempts to read a cache value from a V10 legacy backing store. Backends that do not support V10 legacy migration emit null. Emits exactly one value.

IObservable<byte[]?> TryReadLegacyV10Value(string key, DateTimeOffset now, Type? type)

Parameters

key string

The cache key.

now DateTimeOffset

The current time, used to filter out expired entries.

type Type

Optional type filter.

Returns

IObservable<byte[]>

A one-shot observable that emits the legacy bytes or null.

Upsert(IReadOnlyList<CacheEntry>)

Inserts or replaces a batch of cache entries within a single transaction. Emits a single System.Reactive.Unit on commit.

IObservable<Unit> Upsert(IReadOnlyList<CacheEntry> entries)

Parameters

entries IReadOnlyList<CacheEntry>

The entries to upsert.

Returns

IObservable<Unit>

A one-shot observable that fires on commit.

VacuumExpired(DateTimeOffset)

Removes every row whose expiration is older than now. Emits a single System.Reactive.Unit on commit.

IObservable<Unit> VacuumExpired(DateTimeOffset now)

Parameters

now DateTimeOffset

The wall-clock instant.

Returns

IObservable<Unit>

A one-shot observable that fires on commit.