//namespace Atomx.Data.CacheServices //{ // public partial interface ICacheService // { // /// // /// 通过 slug 获取缓存中的页面主题信息 // /// // /// // /// // /// // Task GetPage(string slug, PageContentModel? data = null); // /// // /// 通过ID获取缓存 // /// // /// // /// // /// // Task GetContent(string slug, bool? reload = null); // } // public partial class CacheService : ICacheService // { // public async Task GetPage(string slug, PageContentModel? data = null) // { // var cacheData = await GetCacheAsync($"{CacheKeys.ContentPrefix}{slug}"); // if (data != null) // { // cacheData = data; // await SetCacheAsync($"{CacheKeys.ContentPrefix}{slug}", cacheData); // } // return cacheData; // } // /// // /// 通过ID获取缓存 // /// // /// // /// // /// // public async Task GetContent(string slug, bool? reload = null) // { // var cacheData = await GetCacheAsync($"{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; // } // } //}