85 lines
3.5 KiB
C#
85 lines
3.5 KiB
C#
//namespace Atomx.Data.CacheServices
|
|
//{
|
|
|
|
// public partial interface ICacheService
|
|
// {
|
|
// /// <summary>
|
|
// /// 通过 slug 获取缓存中的页面主题信息
|
|
// /// </summary>
|
|
// /// <param name="slug"></param>
|
|
// /// <param name="data"></param>
|
|
// /// <returns></returns>
|
|
// Task<PageContentModel?> GetPage(string slug, PageContentModel? data = null);
|
|
|
|
// /// <summary>
|
|
// /// 通过ID获取缓存
|
|
// /// </summary>
|
|
// /// <param name="slug"></param>
|
|
// /// <param name="reload"></param>
|
|
// /// <returns></returns>
|
|
// Task<PageContentModel?> GetContent(string slug, bool? reload = null);
|
|
// }
|
|
// public partial class CacheService : ICacheService
|
|
// {
|
|
// public async Task<PageContentModel?> GetPage(string slug, PageContentModel? data = null)
|
|
// {
|
|
// var cacheData = await GetCacheAsync<PageContentModel>($"{CacheKeys.ContentPrefix}{slug}");
|
|
// if (data != null)
|
|
// {
|
|
// cacheData = data;
|
|
// await SetCacheAsync($"{CacheKeys.ContentPrefix}{slug}", cacheData);
|
|
// }
|
|
|
|
// return cacheData;
|
|
// }
|
|
|
|
// /// <summary>
|
|
// /// 通过ID获取缓存
|
|
// /// </summary>
|
|
// /// <param name="id"></param>
|
|
// /// <param name="reload"></param>
|
|
// /// <returns></returns>
|
|
// public async Task<PageContentModel?> GetContent(string slug, bool? reload = null)
|
|
// {
|
|
// var cacheData = await GetCacheAsync<PageContentModel>($"{CacheKeys.ContentPrefix}{slug}");
|
|
// if (cacheData == null || reload.HasValue)
|
|
// {
|
|
// var content = (from p in _dbContext.Contents
|
|
// where p.Slug == slug && p.Status == (int)ContentStatus.Publish
|
|
// select new PageContentModel
|
|
// {
|
|
// AllowComment = p.AllowComment,
|
|
// Status = p.Status,
|
|
// Body = p.Body,
|
|
// CategoryId = p.CategoryId,
|
|
// CreateTime = p.CreateTime,
|
|
// Description = p.Description,
|
|
// Id = p.Id,
|
|
// Localized = new(),
|
|
// IsTop = p.IsTop,
|
|
// LanguageId = p.LanguageId,
|
|
// MetaDescription = p.MetaDescription,
|
|
// MetaTitle = p.MetaTitle,
|
|
// PublishTime = p.PublishTime,
|
|
// Slug = p.Slug,
|
|
// Title = p.Title,
|
|
// Type = p.Type,
|
|
// UpdateTime = p.UpdateTime,
|
|
// UserId = p.UserId,
|
|
// }).SingleOrDefault();
|
|
// if (content != null)
|
|
// {
|
|
// var Localization = _dbContext.LocalizedProperties.Where(p => p.EntityId == content.Id).ToList();
|
|
|
|
// content.Localized = Localization;
|
|
|
|
// cacheData = content;
|
|
|
|
// await SetCacheAsync($"{CacheKeys.ContentPrefix}{slug}", cacheData);
|
|
// }
|
|
// }
|
|
// return cacheData;
|
|
// }
|
|
// }
|
|
//}
|