Interface IMediaCacheService
Defines operations for the media cache service.
Namespace: Umbraco.Cms.Core.PublishedCache
Assembly: Umbraco.Core.dll
Syntax
public interface IMediaCacheService : IContentCacheService
Remarks
This service provides access to published media content with caching support, including operations for cache seeding, refreshing, and rebuilding.
Methods
View SourceGetByContentType(IPublishedContentType)
Gets all published media items of the specified content type.
Declaration
IEnumerable<IPublishedContent> GetByContentType(IPublishedContentType contentType)
Parameters
| Type | Name | Description |
|---|---|---|
| IPublishedContentType | contentType | The published content type to filter by. |
Returns
| Type | Description |
|---|---|
| IEnumerable<IPublishedContent> | A collection of published media items of the specified type. |
GetByIdAsync(int)
Gets a published media item by its integer identifier.
Declaration
Task<IPublishedContent?> GetByIdAsync(int id)
Parameters
| Type | Name | Description |
|---|---|---|
| int | id | The integer identifier of the media. |
Returns
| Type | Description |
|---|---|
| Task<IPublishedContent> | The published media content, or |
GetByKeyAsync(Guid)
Gets a published media item by its unique key.
Declaration
Task<IPublishedContent?> GetByKeyAsync(Guid key)
Parameters
| Type | Name | Description |
|---|---|---|
| Guid | key | The unique key of the media. |
Returns
| Type | Description |
|---|---|
| Task<IPublishedContent> | The published media content, or |
HasContentByIdAsync(int)
Determines whether media with the specified identifier exists in the cache.
Declaration
Task<bool> HasContentByIdAsync(int id)
Parameters
| Type | Name | Description |
|---|---|---|
| int | id | The integer identifier of the media. |
Returns
| Type | Description |
|---|---|
| Task<bool> |
|
RefreshMediaAsync(IMedia)
Refreshes the cache entry for the specified media item.
Declaration
Task RefreshMediaAsync(IMedia media)
Parameters
| Type | Name | Description |
|---|---|---|
| IMedia | media | The media item to refresh in the cache. |
Returns
| Type | Description |
|---|---|
| Task | A task representing the asynchronous operation. |
TryGetCached(Guid, out IPublishedContent?)
Attempts to retrieve a media item from the in-memory converted-content cache without touching the distributed cache or the database.
Declaration
bool TryGetCached(Guid key, out IPublishedContent? content)
Parameters
| Type | Name | Description |
|---|---|---|
| Guid | key | The unique key of the media. |
| IPublishedContent | content | When this method returns, contains the cached published media if a hit was made; otherwise |
Returns
| Type | Description |
|---|---|
| bool |
|
Remarks
Synchronous fast-path used by sync consumers (e.g. IPublishedMediaCache.GetById(bool, Guid))
to avoid setting up the async state machine on the dominant warm-cache case. On a miss
the caller falls back to the existing async path. The default implementation always
returns false so the caller takes the async path.