InMemoryCacheStorageBackend Class

A CacheStorageBackend that keeps the caches in memory: the default backend of the browsing contexts (see BrowsingContextOptions.CacheStorage). It is thread-safe, and can be shared by several browsing contexts.

public sealed class InMemoryCacheStorageBackend : CacheStorageBackend
Inheritance
CacheStorageBackend InMemoryCacheStorageBackend

Constructors

NameDescription
InMemoryCacheStorageBackend()

InMemoryCacheStorageBackend()

InMemoryCacheStorageBackend.cs
public InMemoryCacheStorageBackend()

No documentation is available.

Methods

NameDescription
ApplyBatch(string, string, IReadOnlyList<long>, IReadOnlyList<CacheEntry>)Changes the entries of a cache atomically (https://w3c.github.io/ServiceWorker/#batch-cache-operations): removes the entries with the ids of removedEntryIds, then appends addedEntries (whose ids are assigned by the backend, greater than the ids of the existing entries).
CreateCache(string, string)Creates an empty cache, and returns true, or returns false when the cache exists.
DeleteCache(string, string)Deletes a cache and its entries, and returns true, or returns false when the cache does not exist.
GetCacheNames(string)Returns the names of the caches of an origin, in creation order (https://w3c.github.io/ServiceWorker/#cache-storage-keys).
GetEntries(string, string, string?)Returns the entries of a cache, in insertion order: all the entries, or the entries whose request URL without its query and its fragment (see CachedRequest.UrlWithoutQuery) is urlWithoutQuery. The library filters the entries further (the query, the method and the Vary header).
GetUsage(string)Returns an estimation of the number of bytes used by the caches of an origin (navigator.storage.estimate()). The default is 0: the usage is not reported.

ApplyBatch(string, string, IReadOnlyList<long>, IReadOnlyList<CacheEntry>)

InMemoryCacheStorageBackend.cs

Changes the entries of a cache atomically (https://w3c.github.io/ServiceWorker/#batch-cache-operations): removes the entries with the ids of removedEntryIds, then appends addedEntries (whose ids are assigned by the backend, greater than the ids of the existing entries).

public override void ApplyBatch(string origin, string name, IReadOnlyList<long> removedEntryIds, IReadOnlyList<CacheEntry> addedEntries)

Parameters

origin string
The serialization of the origin.
name string
The name of the cache.
removedEntryIds IReadOnlyList<long>
The ids of the entries to remove.
addedEntries IReadOnlyList<CacheEntry>
The entries to append.

CreateCache(string, string)

InMemoryCacheStorageBackend.cs

Creates an empty cache, and returns true, or returns false when the cache exists.

public override bool CreateCache(string origin, string name)

Parameters

origin string
The serialization of the origin.
name string
The name of the cache.

Returns

bool

DeleteCache(string, string)

InMemoryCacheStorageBackend.cs

Deletes a cache and its entries, and returns true, or returns false when the cache does not exist.

public override bool DeleteCache(string origin, string name)

Parameters

origin string
The serialization of the origin.
name string
The name of the cache.

Returns

bool

GetCacheNames(string)

InMemoryCacheStorageBackend.cs

Returns the names of the caches of an origin, in creation order (https://w3c.github.io/ServiceWorker/#cache-storage-keys).

public override IReadOnlyList<string> GetCacheNames(string origin)

Parameters

origin string
The serialization of the origin (e.g. https://example.com).

Returns

IReadOnlyList<string>

GetEntries(string, string, string?)

InMemoryCacheStorageBackend.cs

Returns the entries of a cache, in insertion order: all the entries, or the entries whose request URL without its query and its fragment (see CachedRequest.UrlWithoutQuery) is urlWithoutQuery. The library filters the entries further (the query, the method and the Vary header).

public override IReadOnlyList<CacheEntry> GetEntries(string origin, string name, string? urlWithoutQuery)

Parameters

origin string
The serialization of the origin.
name string
The name of the cache.
urlWithoutQuery string?
The URL of the requests without query and fragment, or null for all the entries.

Returns

IReadOnlyList<CacheEntry>

Returns an estimation of the number of bytes used by the caches of an origin (navigator.storage.estimate()). The default is 0: the usage is not reported.

public override long GetUsage(string origin)

Parameters

origin string
The serialization of the origin.

Returns

long