MongoDBHelper
发一个自己改造的MongodbHelper只有自己动手写与大家分享。
驱动用MongoDB: http://www.mongodb.org/downloads
https://files.cnblogs.com/hnlihao/MongoHelper.rar
使用参考
public SlpSystemSettings GetSystemSettings(string accountname, String HostName)
{
string cache = string.Format("SystemSettings/{0}{1}", accountname, HostName);
SlpSystemSettings settings = (SlpSystemSettings)DataCache.GetCache(cache);
if (settings == null) {
if (string.IsNullOrEmpty(HostName)) return GetSystemSettings(accountname);
using (MongoHelper mdr = new MongoHelper(_connectionString, _databaseName))
{
SlpSystemSettings ar = mdr.GetByOne<SlpSystemSettings>(x => x.MDomain == HostName);
if (ar != null)
DataCache.SetCache(cache, settings, cachetime);
}
}
return settings;
}
public List<SlpSecuritySettings> GetSecuritySettings(string policyguid)
{
string cache = string.Format("GSecS/{0}", policyguid);
List<SlpSecuritySettings> securities = (List<SlpSecuritySettings>)DataCache.GetCache(cache);
if (securities == null)
{
using (MongoHelper mdr = new MongoHelper(_connectionString, _databaseName))
{
var qu = from a in mdr.GetCollection<SlpSecuritySettings>().Linq().Where(x => x.Policy_guid == policyguid) select a;
securities = qu.ToList();
if (securities.Count > 0)
DataCache.SetCache(cache, securities, cachetime);
}
}
return securities;
}
初次发文,不知道怎么排版望阅者见谅。
下边想写一个在线监控接口,敬请一起探讨。