/// <summary> /// Evict an entry from the second-level cache. This method occurs outside /// of any transaction; it performs an immediate "hard" remove, so does not respect /// any transaction isolation semantics of the usage strategy. Use with care. /// </summary> /// <param name="factory">The session factory.</param> /// <param name="entityName">The name of the entity to evict.</param> /// <param name="id"></param> /// <param name="tenantIdentifier">Tenant identifier</param> /// <param name="cancellationToken">A cancellation token that can be used to cancel the work</param> public static async Task EvictEntityAsync(this ISessionFactory factory, string entityName, object id, string tenantIdentifier, CancellationToken cancellationToken = default(CancellationToken)) { cancellationToken.ThrowIfCancellationRequested(); if (tenantIdentifier == null) { await(factory.EvictEntityAsync(entityName, id, cancellationToken)).ConfigureAwait(false); } await(ReflectHelper.CastOrThrow <SessionFactoryImpl>(factory, "multi-tenancy").EvictEntityAsync(entityName, id, tenantIdentifier, cancellationToken)).ConfigureAwait(false); }
/// <summary> /// Evict all entries from the second-level cache. This method occurs outside /// of any transaction; it performs an immediate "hard" remove, so does not respect /// any transaction isolation semantics of the usage strategy. Use with care. /// </summary> /// <param name="factory">The session factory.</param> /// <param name="entityNames">The names of the entities to evict.</param> /// <param name="cancellationToken">A cancellation token that can be used to cancel the work</param> public static async Task EvictEntityAsync(this ISessionFactory factory, IEnumerable <string> entityNames, CancellationToken cancellationToken = default(CancellationToken)) { cancellationToken.ThrowIfCancellationRequested(); if (factory is SessionFactoryImpl sfi) { await(sfi.EvictEntityAsync(entityNames, cancellationToken)).ConfigureAwait(false); } else { if (entityNames == null) { throw new ArgumentNullException(nameof(entityNames)); } foreach (var name in entityNames) { await(factory.EvictEntityAsync(name, cancellationToken)).ConfigureAwait(false); } } }
public Task EvictEntityAsync(string entityName, CancellationToken cancellationToken = new CancellationToken()) => _inner.EvictEntityAsync(entityName, cancellationToken);
public Task EvictEntityAsync(string entityName, CancellationToken cancellationToken = new CancellationToken()) { return(_sessionFactory.EvictEntityAsync(entityName, cancellationToken)); }