Table of Contents

Class UploadMemoryCache

Namespace
Supabase.Storage
Assembly
Supabase.Storage.dll

Provides thread-safe in-memory caching for resumable upload URLs with sliding expiration.

public class UploadMemoryCache
Inheritance
UploadMemoryCache
Inherited Members

Properties

Count

Gets the current number of entries in the cache.

public static int Count { get; }

Property Value

int

Methods

Clear()

Removes all cached URLs from the cache.

public static void Clear()

Remove(string)

Removes a cached URL by its key.

public static bool Remove(string key)

Parameters

key string

The unique identifier for the cached URL to remove.

Returns

bool

True if the URL was successfully removed; otherwise, false.

Set(string, string, TimeSpan?)

Stores or updates a resumable upload URL in the cache for the specified key.

public static void Set(string key, string url, TimeSpan? ttl = null)

Parameters

key string

The unique identifier for the cached URL.

url string

The resumable upload URL to cache.

ttl TimeSpan?

Optional time-to-live duration. If not specified, uses the default TTL.

Exceptions

ArgumentException

Thrown when key or url is null, empty, or whitespace.

SetDefaultTtl(TimeSpan)

Sets the default time-to-live duration for future cache entries.

public static void SetDefaultTtl(TimeSpan ttl)

Parameters

ttl TimeSpan

The time-to-live duration. If less than or equal to zero, defaults to 5 minutes.

TryGet(string, out string?)

Attempts to retrieve a cached URL by its key. Updates the sliding expiration on successful retrieval.

public static bool TryGet(string key, out string? url)

Parameters

key string

The unique identifier for the cached URL.

url string

When this method returns, contains the cached URL if found; otherwise, null.

Returns

bool

True if the URL was found in the cache; otherwise, false.