增加项目,分层
This commit is contained in:
1 parent
6e995a5bdb
commit
0a3e5af6a9
234 files changed
+26994
-1
No files matched your search
@@ -0,0 +1,95 @@
|
||||
using MAX.Core.Caches;
|
||||
using Store.Management.Framework.Helpers;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Store.Management.Framework.Caches;
|
||||
|
||||
/// <summary>
|
||||
/// 图片缓存//
|
||||
/// </summary>
|
||||
internal class ImageCache : SingleInstanceCache<ImageCache, StoreImageBase>
|
||||
{
|
||||
|
||||
private ImageCache()
|
||||
{
|
||||
|
||||
}
|
||||
public override void Clear()
|
||||
{
|
||||
base.Clear();
|
||||
GC.Collect();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public byte[] GetBytes(string key)
|
||||
{
|
||||
var item = Get(key);
|
||||
if (item != null)
|
||||
{
|
||||
return item.ImgByte;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public string GetUploadUrl(string key)
|
||||
{
|
||||
var item = Get(key);
|
||||
if (item != null)
|
||||
{
|
||||
return item.UploadImgUrl;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 添加缓存
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="file">图片流</param>
|
||||
/// <returns></returns>
|
||||
public bool TryAdd(string key, byte[] file)
|
||||
{
|
||||
var item = Get(key);
|
||||
if (item == null)
|
||||
{
|
||||
item = new StoreImageBase();
|
||||
item.ImgUrl = key;
|
||||
}
|
||||
item.ImgByte = file;
|
||||
return base.TryAdd(key, item);
|
||||
}
|
||||
/// <summary>
|
||||
/// 添加缓存
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="uploadUrl">图片上传后服务器地址</param>
|
||||
/// <returns></returns>
|
||||
public bool TryAdd(string key, string uploadUrl)
|
||||
{
|
||||
var item = Get(key);
|
||||
if (item == null)
|
||||
{
|
||||
item = new StoreImageBase();
|
||||
item.ImgUrl = key;
|
||||
}
|
||||
if (item.ImgByte == null)
|
||||
{
|
||||
item.UploadImgUrl = uploadUrl;
|
||||
}
|
||||
return base.TryAdd(key, item);
|
||||
}
|
||||
|
||||
public bool TryAdd(StoreImageBase img)
|
||||
{
|
||||
return base.TryAdd(img.ImgUrl, img);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user