diff --git a/src/Business/Grand.Business.Common/Services/Seo/SlugService.cs b/src/Business/Grand.Business.Common/Services/Seo/SlugService.cs
index 1739667f3..0ef1863fc 100644
--- a/src/Business/Grand.Business.Common/Services/Seo/SlugService.cs
+++ b/src/Business/Grand.Business.Common/Services/Seo/SlugService.cs
@@ -36,19 +36,7 @@ public SlugService(ICacheBase cacheBase,
}
#endregion
-
-
- ///
- /// Gets all cached URL Entity
- ///
- /// cached URL Entities
- protected virtual async Task> GetAllUrlEntityCached()
- {
- //cache
- var key = string.Format(CacheKey.URLEntity_ALL_KEY);
- return await _cacheBase.GetAsync(key, async () => await Task.FromResult(_urlEntityRepository.Table.ToList()));
- }
-
+
#region Methods
///
@@ -90,6 +78,7 @@ public virtual async Task UpdateEntityUrl(EntityUrl urlEntity)
//cache
await _cacheBase.RemoveByPrefix(CacheKey.URLEntity_PATTERN_KEY);
}
+
///
/// Deletes an URL Entity
///
@@ -119,9 +108,9 @@ public virtual async Task GetBySlug(string slug)
slug = slug.ToLowerInvariant();
var query = from ur in _urlEntityRepository.Table
- where ur.Slug == slug
- orderby ur.IsActive
- select ur;
+ where ur.Slug == slug
+ orderby ur.IsActive
+ select ur;
return await Task.FromResult(query.FirstOrDefault());
}
@@ -137,17 +126,6 @@ public virtual async Task GetBySlugCached(string slug)
slug = slug.ToLowerInvariant();
- if (_config.LoadAllUrlEntitiesOnStartup)
- {
- var source = await GetAllUrlEntityCached();
- var query = from ur in source
- where ur.Slug != null && ur.Slug.Equals(slug, StringComparison.OrdinalIgnoreCase)
- orderby ur.IsActive
- select ur;
- var entityUrlForCaching = query.FirstOrDefault();
- return entityUrlForCaching;
- }
-
var key = string.Format(CacheKey.URLEntity_BY_SLUG_KEY, slug);
return await _cacheBase.GetAsync(key, async () =>
{
@@ -164,11 +142,11 @@ orderby ur.IsActive
/// Page index
/// Page size
/// URL Entity
- public virtual async Task> GetAllEntityUrl(string slug = "", bool? active = null, int pageIndex = 0, int pageSize = int.MaxValue)
+ public virtual async Task> GetAllEntityUrl(string slug = "", bool? active = null,
+ int pageIndex = 0, int pageSize = int.MaxValue)
{
-
var query = from p in _urlEntityRepository.Table
- select p;
+ select p;
if (!string.IsNullOrWhiteSpace(slug))
query = query.Where(ur => ur.Slug.Contains(slug.ToLowerInvariant()));
@@ -189,39 +167,20 @@ public virtual async Task> GetAllEntityUrl(string slug = "
/// Found slug
public virtual async Task GetActiveSlug(string entityId, string entityName, string languageId)
{
- if (_config.LoadAllUrlEntitiesOnStartup)
- {
- var key = string.Format(CacheKey.URLEntity_ACTIVE_BY_ID_NAME_LANGUAGE_KEY, entityId, entityName, languageId);
- return await _cacheBase.GetAsync(key, async () =>
- {
- var source = await GetAllUrlEntityCached();
- var query = from ur in source
- where ur.EntityId == entityId &&
- ur.EntityName == entityName &&
- ur.LanguageId == languageId &&
- ur.IsActive
- select ur.Slug;
- var slug = query.FirstOrDefault() ?? "";
- return slug;
- });
- }
- else
+ var key = string.Format(CacheKey.URLEntity_ACTIVE_BY_ID_NAME_LANGUAGE_KEY, entityId, entityName,
+ languageId);
+ return await _cacheBase.GetAsync(key, async () =>
{
- var key = string.Format(CacheKey.URLEntity_ACTIVE_BY_ID_NAME_LANGUAGE_KEY, entityId, entityName, languageId);
- return await _cacheBase.GetAsync(key, async () =>
- {
-
- var source = _urlEntityRepository.Table;
- var query = from ur in source
- where ur.EntityId == entityId &&
- ur.EntityName == entityName &&
- ur.LanguageId == languageId &&
- ur.IsActive
- select ur.Slug;
- var slug = await Task.FromResult(query.FirstOrDefault()) ?? "";
- return slug;
- });
- }
+ var source = _urlEntityRepository.Table;
+ var query = from ur in source
+ where ur.EntityId == entityId &&
+ ur.EntityName == entityName &&
+ ur.LanguageId == languageId &&
+ ur.IsActive
+ select ur.Slug;
+ var slug = await Task.FromResult(query.FirstOrDefault()) ?? "";
+ return slug;
+ });
}
///
@@ -231,7 +190,8 @@ public virtual async Task GetActiveSlug(string entityId, string entityNa
/// Entity
/// Slug
/// Language ID
- public virtual async Task SaveSlug(T entity, string slug, string languageId) where T : BaseEntity, ISlugEntity
+ public virtual async Task SaveSlug(T entity, string slug, string languageId)
+ where T : BaseEntity, ISlugEntity
{
if (entity == null)
throw new ArgumentNullException(nameof(entity));
@@ -240,10 +200,10 @@ public virtual async Task SaveSlug(T entity, string slug, string languageId)
var entityName = typeof(T).Name;
var query = from ur in _urlEntityRepository.Table
- where ur.EntityId == entityId &&
- ur.EntityName == entityName &&
- ur.LanguageId == languageId
- select ur;
+ where ur.EntityId == entityId &&
+ ur.EntityName == entityName &&
+ ur.LanguageId == languageId
+ select ur;
var allUrlEntity = query.ToList();
var activeUrlEntity = allUrlEntity.FirstOrDefault(x => x.IsActive);
@@ -265,8 +225,7 @@ public virtual async Task SaveSlug(T entity, string slug, string languageId)
else
{
//new record
- var entityUrl = new EntityUrl
- {
+ var entityUrl = new EntityUrl {
EntityId = entityId,
EntityName = entityName,
Slug = slug,
@@ -301,8 +260,7 @@ public virtual async Task SaveSlug(T entity, string slug, string languageId)
else
{
//insert new record
- var entityUrl = new EntityUrl
- {
+ var entityUrl = new EntityUrl {
EntityId = entityId,
EntityName = entityName,
Slug = slug,
@@ -314,7 +272,6 @@ public virtual async Task SaveSlug(T entity, string slug, string languageId)
activeUrlEntity.IsActive = false;
await UpdateEntityUrl(activeUrlEntity);
}
-
}
}
}
diff --git a/src/Core/Grand.Infrastructure/Caching/Constants/CommonCacheKey.cs b/src/Core/Grand.Infrastructure/Caching/Constants/CommonCacheKey.cs
index fb418c6d9..13d358f18 100644
--- a/src/Core/Grand.Infrastructure/Caching/Constants/CommonCacheKey.cs
+++ b/src/Core/Grand.Infrastructure/Caching/Constants/CommonCacheKey.cs
@@ -136,11 +136,6 @@ public static partial class CacheKey
///
public static string URLEntity_ACTIVE_BY_ID_NAME_LANGUAGE_KEY => "Grand.urlEntity.active.id-name-language-{0}-{1}-{2}";
- ///
- /// Key for caching
- ///
- public static string URLEntity_ALL_KEY => "Grand.urlEntity.all";
-
///
/// Key for caching
///
diff --git a/src/Core/Grand.Infrastructure/Configuration/PerformanceConfig.cs b/src/Core/Grand.Infrastructure/Configuration/PerformanceConfig.cs
index 54c10e67b..145536103 100644
--- a/src/Core/Grand.Infrastructure/Configuration/PerformanceConfig.cs
+++ b/src/Core/Grand.Infrastructure/Configuration/PerformanceConfig.cs
@@ -25,11 +25,6 @@ public partial class PerformanceConfig
///
public bool DisplayMiniProfilerInPublicStore { get; set; }
- ///
- /// A value indicating whether to load all search engine friendly names (slugs) on application startup
- ///
- public bool LoadAllUrlEntitiesOnStartup { get; set; }
-
///
/// Gets or sets a value indicating whether we compress response
///
diff --git a/src/Web/Grand.Web/App_Data/appsettings.json b/src/Web/Grand.Web/App_Data/appsettings.json
index 931101e36..887e81f66 100644
--- a/src/Web/Grand.Web/App_Data/appsettings.json
+++ b/src/Web/Grand.Web/App_Data/appsettings.json
@@ -121,9 +121,6 @@
//Gets or sets a value indicating for default cache time in minutes"
"DefaultCacheTimeMinutes": 60,
- //A value indicating whether to load all search engine friendly names (slugs) on application startup
- "LoadAllUrlEntitiesOnStartup": false,
-
/// A value indicating whether to ignore ACL rules
"IgnoreAcl": false,