Interface IRepositoryCacheVersionAccessor
Provides access to repository cache version information with request-level caching.
Namespace: Umbraco.Cms.Core.Cache
Assembly: Umbraco.Core.dll
Syntax
public interface IRepositoryCacheVersionAccessor
Remarks
This accessor retrieves cache version information from the database and caches it at the request level to minimize database queries. Cache versions are used to determine if cached repository data is still valid in distributed environments.
Methods
View SourceCachesSynced()
Notifies the accessor that caches have been synchronized.
Declaration
[Obsolete("Use the overload that takes the adopted versions. Scheduled for removal in Umbraco 19.")]
void CachesSynced()
Remarks
Clears the cached versions, so the next check reads them from the database again.
CachesSynced(IEnumerable<RepositoryCacheVersion>)
Notifies the accessor that caches have been synchronized and which versions were adopted.
Declaration
void CachesSynced(IEnumerable<RepositoryCacheVersion> adoptedVersions)
Parameters
| Type | Name | Description |
|---|---|---|
| IEnumerable<RepositoryCacheVersion> | adoptedVersions | The versions the local caches now hold. |
Remarks
The scope-level cache is moved to the adopted versions instead of being cleared: a scope holds its distributed locks for the rest of its transaction, so the data it reads cannot change under it and checking the database version again would only trigger another sync for a version published after its locks were taken. The request-level cache is cleared, so a later root scope in the same request reads the current versions again. Clearing the scope-level cache instead would let a version published mid-scope change that scope's view, so the default implementation throws rather than fall back to CachesSynced().
Exceptions
| Type | Condition |
|---|---|
| NotImplementedException | Thrown when the implementation does not retain the adopted snapshot. |
GetAsync(string)
Retrieves the cache version for the specified cache key.
Declaration
Task<RepositoryCacheVersion?> GetAsync(string cacheKey)
Parameters
| Type | Name | Description |
|---|---|---|
| string | cacheKey | The unique identifier for the cache entry. |
Returns
| Type | Description |
|---|---|
| Task<RepositoryCacheVersion> | The cache version if found, or null if the version doesn't exist or the request is a client-side request. |
VersionChanged(string)
Notifies of a version change on a given cache key.
Declaration
[Obsolete("Use version that takes newVersion, scheduled for removal in V19")]
void VersionChanged(string cacheKey)
Parameters
| Type | Name | Description |
|---|---|---|
| string | cacheKey | Key of the changed version. |
VersionChanged(string, Guid)
Notifies of a version change on a given cache key, providing the new version so internal caches can be updated in-place without a database round-trip.
Declaration
void VersionChanged(string cacheKey, Guid newVersion)
Parameters
| Type | Name | Description |
|---|---|---|
| string | cacheKey | Key of the changed version. |
| Guid | newVersion | The new version GUID that was just written to the database. |