提交 cb5c64e1 编写于 作者: JasonWcx's avatar JasonWcx

Runtime中增加api Cache

上级 30ac0b08
......@@ -49,7 +49,7 @@ namespace Mozi.HttpEmbedded.Cache
cache.IsPrivate = isprivate;
if (isNew)
{
_caches.Insert(0,cache);
_caches.Add(cache);
}
}
}
......@@ -59,7 +59,7 @@ namespace Mozi.HttpEmbedded.Cache
/// <param name="name"></param>
/// <param name="param"></param>
/// <returns></returns>
public CacheInfo Get(string name, string param)
public CacheInfo Find(string name, string param)
{
lock (_sync)
{
......
......@@ -2,6 +2,7 @@
using System.Linq;
using System.Net.Sockets;
using Mozi.HttpEmbedded.Auth;
using Mozi.HttpEmbedded.Cache;
using Mozi.HttpEmbedded.Cert;
using Mozi.HttpEmbedded.Common;
using Mozi.HttpEmbedded.Compress;
......@@ -53,7 +54,7 @@ namespace Mozi.HttpEmbedded
/// <summary>
/// 默认为程序集运行路径的TEMP目录
/// </summary>
private string _tempPath = AppDomain.CurrentDomain.BaseDirectory+@"Temp\";
private string _tempPath = AppDomain.CurrentDomain.BaseDirectory + @"Temp\";
private string _serverRoot = AppDomain.CurrentDomain.BaseDirectory;
private string _serverName = "HttpEmbedded";
......@@ -70,6 +71,9 @@ namespace Mozi.HttpEmbedded
private CertManager _certMg;
//HTTPS开启标识
private bool _httpsEnabled = false;
private MemoryCache _cache = new MemoryCache();
/// <summary>
/// 服务器启动时间
/// </summary>
......@@ -155,6 +159,9 @@ namespace Mozi.HttpEmbedded
get { return _serverRoot; }
private set { _serverRoot = value; }
}
internal MemoryCache Cache { get { return _cache; } }
public HttpServer()
{
StartTime = DateTime.MinValue;
......
......@@ -229,13 +229,35 @@ namespace Mozi.HttpEmbedded.Page
/// <summary>
/// 全局缓存-内存型
/// </summary>
/// <param name="action">query|add|remove|clear</param>
/// <param name="name"></param>
/// <param name="param"></param>
/// <param name="data"></param>
/// <returns></returns>
internal ResponseMessage Cache()
public ResponseMessage Cache(string action,string name,string param,string data)
{
ResponseMessage rm = new ResponseMessage
ResponseMessage rm = new ResponseMessage();
if (action == "query")
{
success = true
};
rm.data=Context.Server.Cache.Find(name, param);
}
else if (action == "add")
{
Context.Server.Cache.Add(name,param,data);
}
else if (action == "remove")
{
Context.Server.Cache.Remove(name,param);
}
else if (action == "clear")
{
Context.Server.Cache.ClearExpired();
}
else
{
rm.success = false;
}
rm.success = true;
return rm;
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册