Class UploadMemoryCache
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
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
keystringThe 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
keystringThe unique identifier for the cached URL.
urlstringThe resumable upload URL to cache.
ttlTimeSpan?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
ttlTimeSpanThe 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
keystringThe unique identifier for the cached URL.
urlstringWhen this method returns, contains the cached URL if found; otherwise, null.
Returns
- bool
True if the URL was found in the cache; otherwise, false.