Search Results for

    Show / Hide Table of Contents
    View Source

    Class IdKeyMap

    Provides bidirectional mapping between integer IDs and GUIDs (keys) for Umbraco entities.

    Inheritance
    object
    Namespace: Umbraco.Cms.Core.Services
    Assembly: Umbraco.Core.dll
    Syntax
    public class IdKeyMap : IIdKeyMap
    Remarks

    This class provides an efficient caching layer for ID/Key lookups. The cache assumes that the id/guid map is unique; that is, if an id and a guid map to each other, then the id will never map to another guid, and the guid will never map to another id.

    Cache is cleared by MediaCacheRefresher, UnpublishedPageCacheRefresher, and other refreshers - because id/guid map is unique, we only clear to avoid leaking memory, as we don't risk caching obsolete values - and only when actually deleting.

    External mappers can be registered (e.g., from NuCache) to provide lookups from alternative sources before hitting the database.

    Constructors

    View Source

    IdKeyMap(ICoreScopeProvider, IIdKeyMapRepository)

    Initializes a new instance of the IdKeyMap class.

    Declaration
    public IdKeyMap(ICoreScopeProvider scopeProvider, IIdKeyMapRepository idKeyMapRepository)
    Parameters
    Type Name Description
    ICoreScopeProvider scopeProvider

    The core scope provider for database operations.

    IIdKeyMapRepository idKeyMapRepository

    The repository for ID/Key mapping data access.

    Methods

    View Source

    ClearCache()

    Clears the entire ID/key mapping cache.

    Declaration
    public void ClearCache()
    Remarks

    Invoked on UnpublishedPageCacheRefresher.RefreshAll. For specific items, use the ID or Key specific overloads.

    View Source

    ClearCache(Guid)

    Clears the cache entry for a specific GUID key.

    Declaration
    public void ClearCache(Guid key)
    Parameters
    Type Name Description
    Guid key

    The GUID key to remove from the cache.

    View Source

    ClearCache(int)

    Clears the cache entry for a specific integer ID.

    Declaration
    public void ClearCache(int id)
    Parameters
    Type Name Description
    int id

    The integer identifier to remove from the cache.

    View Source

    Dispose()

    Declaration
    public void Dispose()
    View Source

    Dispose(bool)

    Releases the unmanaged resources used by the IdKeyMap and optionally releases the managed resources.

    Declaration
    protected virtual void Dispose(bool disposing)
    Parameters
    Type Name Description
    bool disposing

    true to release both managed and unmanaged resources; false to release only unmanaged resources.

    View Source

    GetIdForKey(Guid, UmbracoObjectTypes)

    Gets the integer ID for a given GUID key and object type.

    Declaration
    public Attempt<int> GetIdForKey(Guid key, UmbracoObjectTypes umbracoObjectType)
    Parameters
    Type Name Description
    Guid key

    The unique GUID key of the entity.

    UmbracoObjectTypes umbracoObjectType

    The type of the Umbraco object.

    Returns
    Type Description
    Attempt<int>

    An attempt containing the integer ID if found.

    View Source

    GetIdForUdi(Udi)

    Gets the integer ID for a given UDI.

    Declaration
    public Attempt<int> GetIdForUdi(Udi udi)
    Parameters
    Type Name Description
    Udi udi

    The Umbraco Document Identifier.

    Returns
    Type Description
    Attempt<int>

    An attempt containing the integer ID if found.

    View Source

    GetKeyForId(int, UmbracoObjectTypes)

    Gets the GUID key for a given integer ID and object type.

    Declaration
    public Attempt<Guid> GetKeyForId(int id, UmbracoObjectTypes umbracoObjectType)
    Parameters
    Type Name Description
    int id

    The integer identifier of the entity.

    UmbracoObjectTypes umbracoObjectType

    The type of the Umbraco object.

    Returns
    Type Description
    Attempt<Guid>

    An attempt containing the GUID key if found.

    View Source

    GetUdiForId(int, UmbracoObjectTypes)

    Gets the UDI for a given integer ID and object type.

    Declaration
    public Attempt<Udi?> GetUdiForId(int id, UmbracoObjectTypes umbracoObjectType)
    Parameters
    Type Name Description
    int id

    The integer identifier of the entity.

    UmbracoObjectTypes umbracoObjectType

    The type of the Umbraco object.

    Returns
    Type Description
    Attempt<Udi>

    An attempt containing the UDI if found.

    View Source

    SetMapper(UmbracoObjectTypes, Func<int, Guid>, Func<Guid, int>)

    Declaration
    public void SetMapper(UmbracoObjectTypes umbracoObjectType, Func<int, Guid> id2key, Func<Guid, int> key2id)
    Parameters
    Type Name Description
    UmbracoObjectTypes umbracoObjectType
    Func<int, Guid> id2key
    Func<Guid, int> key2id
    • View Source
    In this article
    Back to top Copyright © 2016-present Umbraco
    Generated by DocFX