Class MemberRepositoryUsernameCachePolicy
Represents a cache policy that determines how usernames are cached in the member repository. This policy controls the caching behavior for member username lookups to improve performance and consistency.
Inheritance
Namespace: Umbraco.Cms.Core.Cache
Assembly: Umbraco.Infrastructure.dll
Syntax
public class MemberRepositoryUsernameCachePolicy : DefaultRepositoryCachePolicy<IMember, string>, IRepositoryCachePolicy<IMember, string>
Constructors
View SourceMemberRepositoryUsernameCachePolicy(IAppPolicyCache, IScopeAccessor, RepositoryCachePolicyOptions)
Initializes a new instance of the MemberRepositoryUsernameCachePolicy class.
Declaration
[Obsolete("Please use the constructor with all parameters. Scheduled for removal in Umbraco 18.")]
public MemberRepositoryUsernameCachePolicy(IAppPolicyCache cache, IScopeAccessor scopeAccessor, RepositoryCachePolicyOptions options)
Parameters
| Type | Name | Description |
|---|---|---|
| IAppPolicyCache | cache | The IAppPolicyCache instance used for caching member data by username. |
| IScopeAccessor | scopeAccessor | The IScopeAccessor used to manage the current scope for cache operations. |
| RepositoryCachePolicyOptions | options | The RepositoryCachePolicyOptions that configure cache policy behavior for the repository. |
MemberRepositoryUsernameCachePolicy(IAppPolicyCache, IScopeAccessor, RepositoryCachePolicyOptions, IRepositoryCacheVersionService, ICacheSyncService)
Initializes a new instance of the MemberRepositoryUsernameCachePolicy class, which defines the caching policy for member repository lookups by username.
Declaration
public MemberRepositoryUsernameCachePolicy(IAppPolicyCache cache, IScopeAccessor scopeAccessor, RepositoryCachePolicyOptions options, IRepositoryCacheVersionService repositoryCacheVersionService, ICacheSyncService cacheSyncService)
Parameters
| Type | Name | Description |
|---|---|---|
| IAppPolicyCache | cache | The application-level policy cache used for storing cached member data. |
| IScopeAccessor | scopeAccessor | Provides access to the current scope for cache operations. |
| RepositoryCachePolicyOptions | options | Configuration options for the repository cache policy. |
| IRepositoryCacheVersionService | repositoryCacheVersionService | Service for managing cache versioning within the repository. |
| ICacheSyncService | cacheSyncService | Service responsible for synchronizing cache across distributed environments. |
Methods
View SourceDeleteByUserName(string, string?)
Removes the cache entry for a member associated with the specified user name and key.
Declaration
public void DeleteByUserName(string key, string? username)
Parameters
| Type | Name | Description |
|---|---|---|
| string | key | A string used as part of the cache key to identify the cache entry. |
| string | username | The user name of the member whose cache entry should be removed. Can be |
Remarks
This method also registers a cache change notification for other servers in a distributed environment.
GetByUserName(string, string?, Func<string?, IMember?>, Func<string[]?, IEnumerable<IMember>?>)
Retrieves a member by username, first attempting to get it from the cache. If not present, fetches the member using the provided delegate and caches the result.
Declaration
public IMember? GetByUserName(string key, string? username, Func<string?, IMember?> performGetByUsername, Func<string[]?, IEnumerable<IMember>?> performGetAll)
Parameters
| Type | Name | Description |
|---|---|---|
| string | key | A prefix used to construct the cache key for the member. |
| string | username | The username of the member to retrieve. |
| Func<string, IMember> | performGetByUsername | A delegate to fetch the member by username if it is not found in the cache. |
| Func<string[], IEnumerable<IMember>> | performGetAll | A delegate to fetch all members. This parameter is required by the interface but is not used in this method. |
Returns
| Type | Description |
|---|---|
| IMember | The IMember matching the specified username if found; otherwise, |