Interface IAssetPrefetcherService
Core interface for asset prefetching functionality. Provides methods to prefetch assets, manage contexts, and query cache status.
Namespace: Serenity.AssetPrefetcher.Application.Interfaces
Assembly: Serenity.AssetPrefetcher.Application.dll
Syntax
public interface IAssetPrefetcherService : IService, IFoundationSettings
Methods
IsCached(AssetKey)
Checks if a specific asset is currently cached.
Declaration
bool IsCached(AssetKey key)
Parameters
| Type | Name | Description |
|---|---|---|
| AssetKey | key | Key identifying the asset to check |
Returns
| Type | Description |
|---|---|
| bool | True if the asset is cached, false otherwise |
PrefetchAsync(string, AssetKey, PrefetchPriority)
Prefetches a single asset asynchronously with specified priority.
Declaration
Task PrefetchAsync(string contextId, AssetKey key, PrefetchPriority priority)
Parameters
| Type | Name | Description |
|---|---|---|
| string | contextId | Unique identifier for the prefetch context |
| AssetKey | key | Key identifying the asset to prefetch |
| PrefetchPriority | priority | Priority level for the prefetch operation |
Returns
| Type | Description |
|---|---|
| Task | Task representing the async prefetch operation |
PrewarmContextAsync(string, AssetKey[], PrefetchPolicy)
Preloads multiple assets for a specific context using a defined policy.
Declaration
Task PrewarmContextAsync(string contextId, AssetKey[] keys, PrefetchPolicy policy)
Parameters
| Type | Name | Description |
|---|---|---|
| string | contextId | Unique identifier for the context |
| AssetKey[] | keys | Array of asset keys to preload |
| PrefetchPolicy | policy | Policy defining how the assets should be prefetched |
Returns
| Type | Description |
|---|---|
| Task | Task representing the async prewarming operation |
QueryCacheAsync(IEnumerable<AssetKey>, CancellationToken)
Queries the cache status for multiple assets asynchronously.
Declaration
Task<IReadOnlyDictionary<AssetKey, CacheStatusInfo>> QueryCacheAsync(IEnumerable<AssetKey> keys, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| IEnumerable<AssetKey> | keys | Collection of asset keys to query |
| CancellationToken | cancellationToken | Cancellation token for the async operation |
Returns
| Type | Description |
|---|---|
| Task<IReadOnlyDictionary<AssetKey, CacheStatusInfo>> | Dictionary mapping asset keys to their cache status information |
ReleaseContext(string)
Releases all assets associated with a specific context from cache.
Declaration
void ReleaseContext(string contextId)
Parameters
| Type | Name | Description |
|---|---|---|
| string | contextId | Unique identifier for the context to release |
TryGetDiagnostics(out PrefetcherDiagnostics)
Attempts to retrieve current cache diagnostics information.
Declaration
bool TryGetDiagnostics(out PrefetcherDiagnostics diagnostics)
Parameters
| Type | Name | Description |
|---|---|---|
| PrefetcherDiagnostics | diagnostics | Output parameter containing the diagnostics data |
Returns
| Type | Description |
|---|---|
| bool | True if diagnostics were successfully retrieved, false otherwise |