| 123456789101112131415161718192021222324252627282930313233343536373839404142 |
- using System;
- using Abp.UI;
- using IwbZero.ToolCommon;
- using IwbZero.ToolCommon.CacheHelpers;
- using IwbZero.ToolCommon.StringModel;
- namespace WeEngine.Components
- {
- public class EngineComponentCache : InfoCache<EngineComponent>
- {
- public static readonly EngineComponentCache Instance = new EngineComponentCache();
- public EngineComponentCache() : base(60* 24, 60* 1)
- {
- }
- public void SetCache(EngineComponent component)
- {
- Instance.AddCache(component.Id + "", component);
- }
- public EngineComponent GetCache(string id)
- {
- if (!Instance.TryGetCache(id, out var component))
- {
- try
- {
- string url = "";
- var result = url.RequestPost(new { Id = id }.Obj2String());
- component = result.Str2Obj<EngineComponent>();
- if (component != null)
- {
- SetCache(component);
- }
- }
- catch (Exception e)
- {
- throw new UserFriendlyException($"没有找到Id为{id}的引擎组件!{e.Message}");
- }
- }
- return component;
- }
- }
- }
|