Sry.Framework.Web/CachePool.cs
(开头部分) 2KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web;
using System.Web.Caching;
namespace Sry.Framework.Web
{
public class CachePool<T>
{
private object syncLock = new object();
public CacheItemRemovedCallback OnCacheLose { get; set; }
public CacheItemPriority Priority { get; set; }
public DateTime Expire { get; set; }
private List<T> data {
get {
var fx = HttpRuntime.Cache[typeof(T).Name] as List<T>;
if (fx == null) {
fx = new List<T>();
HttpRuntime.Cache.Add(typeof(T).Name, fx, null, Expire, Cache.NoSlidingExpiration,
Priority, OnCacheLose);
}
return fx;
}
}
public bool HasData {
get {
lock (syncLock) {
return (data.Count > 0);
}
}
}
public void Add(T item)
{
lock (syncLock)
{
data.Add(item);
}
}
public void AddRange(IEnumerable<T> collection)
{
lock (syncLock)
{
data.AddRange(collection);
}
}
public void ForEach(Func<T, bool> func)
{
后面还有 39 行代码,购买后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。