本文整理汇总了C#中DataCache.Put方法的典型用法代码示例。如果您正苦于以下问题:C# DataCache.Put方法的具体用法?C# DataCache.Put怎么用?C# DataCache.Put使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataCache
的用法示例。
在下文中一共展示了DataCache.Put方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetUserByIDIncludeEntidade
public UserProfile GetUserByIDIncludeEntidade(int id)
{
m_cache = CacheUtil.GetCache();
DataCacheItemVersion version = null;
UserProfile result = (UserProfile)m_cache.Get("UserProfileGetUserByIDIncludeEntidade_" + id, out version);
if (result == null)
{
result = context.UserProfiles.Include("entidade").Single(u => u.UserId == id);
m_cache.Put("UserProfileGetUserByIDIncludeEntidade_" + id, result);
}
return result;
}
示例2: FindByUsername
public UserProfile FindByUsername(string username)
{
m_cache = CacheUtil.GetCache();
DataCacheItemVersion version = null;
UserProfile result = (UserProfile)m_cache.Get("UserProfileFindByUsername_" + username, out version);
if (result == null)
{
result = context.UserProfiles.Single(u => u.UserName == username);
m_cache.Put("UserProfileFindByUsername_" + username, result);
}
return result;
}
示例3: GetPorTipologia
public List<ValorSistema> GetPorTipologia(string tipologia)
{
m_cache = CacheUtil.GetCache();
DataCacheItemVersion version = null;
List<ValorSistema> result = (List<ValorSistema>)m_cache.Get("ValoresSistema_" + tipologia, out version);
if (result == null)
{
result = context.ValoresSistema.Where(v => v.tipologia == tipologia).ToList();
m_cache.Put("ValoresSistema_" + tipologia, result);
}
return result;
}
示例4: FindCache
public Apolice FindCache(int id)
{
m_cache = CacheUtil.GetCache();
DataCacheItemVersion version = null;
Apolice apo = (Apolice) m_cache.Get("Apolice_" + id.ToString(), out version);
if (apo == null)
{
apo = context.Apolices.Include("tomador").Include("veiculo").Include("veiculo.categoria").Include("concelho").
Include("avisosApolice").Include("eventoHistorico").Single(a => a.apoliceId == id);
m_cache.Put("Apolice_" + id.ToString(), apo);
}
return apo;
//return context.Apolices.Find(id);
}
示例5: GetAll
public IQueryable<Video> GetAll()
{
var dataCache = new DataCache();
var videos = dataCache.Get("videoList") as IEnumerable<Video>;
if (videos == null)
{
videos = this.context.Videos.OrderByDescending(v => v.Id);
dataCache.Put("videoList", videos.ToList());
Thread.Sleep(500);
}
return videos.AsQueryable();
}
示例6: Index
public ActionResult Index(
IndexModel indexModel,
string button)
{
var dataCache = new DataCache("default");
if (button.Equals("set"))
{
dataCache.Put(indexModel.Name, indexModel.Value);
}
else
{
var value = dataCache.Get(indexModel.Name);
if (value != null)
{
ModelState.Remove("Value");
indexModel.Value = (string)value;
}
}
return View(indexModel);
}
示例7: SetToken
public void SetToken(Guid token)
{
var mycache = new DataCache();
mycache.Put(CacheKey, token);
}
示例8: ActivateOptions
public override void ActivateOptions()
{
base.ActivateOptions();
try
{
DataCacheFactory factory;
if (this.Hosts.Count != 0)
{
LogLog.Debug(declaringType, "Activating host options");
DataCacheFactoryConfiguration config = new DataCacheFactoryConfiguration();
List<DataCacheServerEndpoint> servers = new List<DataCacheServerEndpoint>();
for (int i = 0; i < this.Hosts.Count; i++)
{
servers.Add(new DataCacheServerEndpoint(this.Hosts[i].Host, this.Hosts[i].Port));
}
config.Servers = servers;
factory = new DataCacheFactory(config);
}
else
{
LogLog.Debug(declaringType, "No host options detected, using default cache factory");
factory = new DataCacheFactory();
}
_Cache = factory.GetCache(this.CacheName);
//config region exists before we attempt to write to it.
_Cache.CreateRegion(this.RegionName);
var obj = _Cache.Get(Shared.LAST_PUSHED_KEY_KEY, this.RegionName);
if (obj == null)
{
_Cache.Put(Shared.LAST_PUSHED_KEY_KEY, "0", this.RegionName);
}
}
catch (Exception ex)
{
this.ErrorHandler.Error("Could not create connection to App Fabric", ex);
this._Cache = null;
}
}
示例9: PutInfo
public void PutInfo(DataCache _cache, string key, string value)
{
_cache.Put(key, value);
}
示例10: Catalog
public Catalog(DataCache cache)
{
_cache = cache;
var entries = _cache.Get(CacheProvider.CacheEntriesKey);
if (entries == null)
{
entries = new Dictionary<string, DateTime>();
_cache.Put(CacheProvider.CacheEntriesKey, entries);
}
_entries = (Dictionary<string, DateTime>)_cache.GetAndLock(CacheProvider.CacheEntriesKey, new TimeSpan(0, 0, 60), out _lockHandle);
}
示例11: GetUserByEntidade
public IQueryable<UserProfile> GetUserByEntidade(int entidadeId)
{
m_cache = CacheUtil.GetCache();
DataCacheItemVersion version = null;
IQueryable<UserProfile> result = (IQueryable<UserProfile>)m_cache.Get("UserProfileGetUserByEntidade" + entidadeId, out version);
if (result == null)
{
result = context.UserProfiles.Where(u => u.entidadeId == entidadeId);
m_cache.Put("UserProfileGetUserByEntidade_" + entidadeId, result);
}
return result;
=======
>>>>>>> 6bef4ea7199f182f1dcc5a1156a157494ff9f29c
}
示例12: CacheDemo
public ActionResult CacheDemo(string toCache)
{
var cache = new DataCache();
cache.Put("key", toCache);
return View();
}