Browse Source

Fix conflicts

cmskit-cache
Enis Necipoglu 1 year ago
parent
commit
e573489506
No known key found for this signature in database GPG Key ID: 1EC55E13241E1680
  1. 9
      modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/Pages/PageAdminAppService.cs
  2. 6
      modules/cms-kit/src/Volo.CmsKit.Common.Application.Contracts/Volo/CmsKit/Pages/CmsKitPublicPagesCache.cs
  3. 8
      modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKitPageRouteValueTransformer.cs
  4. 47
      modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKitRemotePageStore.cs

9
modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/Pages/PageAdminAppService.cs

@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.Extensions.Caching.Distributed;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Caching;
using Volo.Abp.Data;
@ -29,16 +30,20 @@ public class PageAdminAppService : CmsKitAdminAppServiceBase, IPageAdminAppServi
protected IDistributedCache<PageCacheItem> PageCache { get; }
protected IDistributedCache DistributedCache { get; }
public PageAdminAppService(
IPageRepository pageRepository,
PageManager pageManager,
IDistributedCache<PageCacheItem> pageCache,
ICommentRepository commentRepository)
ICommentRepository commentRepository,
IDistributedCache distributedCache)
{
PageRepository = pageRepository;
PageManager = pageManager;
PageCache = pageCache;
CommentRepository = commentRepository;
DistributedCache = distributedCache;
}
public virtual async Task<PageDto> GetAsync(Guid id)
@ -128,5 +133,7 @@ public class PageAdminAppService : CmsKitAdminAppServiceBase, IPageAdminAppServi
protected virtual async Task InvalidateDefaultHomePageCacheAsync(bool considerUow = false)
{
await PageCache.RemoveAsync(PageCacheItem.GetKey(PageConsts.DefaultHomePageCacheKey), considerUow: considerUow);
await DistributedCache.RemoveAsync(CmsKitPublicPagesCache.CacheKey);
}
}

6
modules/cms-kit/src/Volo.CmsKit.Common.Application.Contracts/Volo/CmsKit/Pages/CmsKitPublicPagesCache.cs

@ -0,0 +1,6 @@
namespace Volo.CmsKit.Pages;
public static class CmsKitPublicPagesCache
{
public const string CacheKey = "CmsKitPagesList";
}

8
modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKitPageRouteValueTransformer.cs

@ -12,12 +12,12 @@ namespace Volo.CmsKit.Public.Web.Pages;
public class CmsKitPageRouteValueTransformer : DynamicRouteValueTransformer, ITransientDependency
{
protected IFeatureChecker FeatureChecker { get; }
protected IPagePublicAppService PagePublicAppService { get; }
protected CmsKitRemotePageStore RemotePageStore { get; }
public CmsKitPageRouteValueTransformer(IFeatureChecker featureChecker, IPagePublicAppService pagePublicAppService)
public CmsKitPageRouteValueTransformer(IFeatureChecker featureChecker, CmsKitRemotePageStore remotePageStore)
{
FeatureChecker = featureChecker;
PagePublicAppService = pagePublicAppService;
RemotePageStore = remotePageStore;
}
public override async ValueTask<RouteValueDictionary> TransformAsync(HttpContext httpContext, RouteValueDictionary values)
@ -30,7 +30,7 @@ public class CmsKitPageRouteValueTransformer : DynamicRouteValueTransformer, ITr
}
var slug = slugParameter.ToString().TrimStart('/');
var exist = await PagePublicAppService.DoesSlugExistAsync(slug);
var exist = await RemotePageStore.DoesSlugExistAsync(slug);
if (exist)
{

47
modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKitRemotePageStore.cs

@ -0,0 +1,47 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using Volo.Abp.Caching;
using Volo.Abp.DependencyInjection;
using Volo.CmsKit.Pages;
using Volo.CmsKit.Public.Pages;
namespace Volo.CmsKit.Public.Web.Pages;
public class CmsKitRemotePageStore : ITransientDependency
{
protected IDistributedCache<CmsKitPageSlugCacheItem> Cache { get; }
protected IPagePublicAppService PagePublicAppService { get; }
public CmsKitRemotePageStore(
IDistributedCache<CmsKitPageSlugCacheItem> cache,
IPagePublicAppService pagePublicAppService)
{
Cache = cache;
PagePublicAppService = pagePublicAppService;
}
public virtual async Task<bool> DoesSlugExistAsync(string slug)
{
var cacheItem = await Cache.GetAsync(CmsKitPublicPagesCache.CacheKey);
if (cacheItem == null)
{
cacheItem = new CmsKitPageSlugCacheItem();
cacheItem.Items[slug] = await PagePublicAppService.DoesSlugExistAsync(slug);
await Cache.SetAsync(CmsKitPublicPagesCache.CacheKey, cacheItem);
}
if (cacheItem.Items.TryGetValue(slug, out var exist))
{
return exist;
}
return false;
}
}
public class CmsKitPageSlugCacheItem
{
public Dictionary<string, bool> Items { get; set; } = new();
}
Loading…
Cancel
Save