本文整理汇总了C#中DataCache.Get方法的典型用法代码示例。如果您正苦于以下问题:C# DataCache.Get方法的具体用法?C# DataCache.Get怎么用?C# DataCache.Get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataCache
的用法示例。
在下文中一共展示了DataCache.Get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AzureDataCacheIndexInput
public AzureDataCacheIndexInput(string name, string cacheRegion, DataCache persistantCache)
{
_persistantCache = persistantCache;
_name = name;
_cacheRegion = cacheRegion;
var data = _persistantCache.Get(name, _cacheRegion);
byte[] streamData = data == null ? new byte[] { } : (byte[])data;
_stream = new MemoryStream(streamData, false);
}
示例2: getTweets
Tweets getTweets(string name)
{
DataCache cache = new DataCache();
Tweets entries = cache.Get(name) as Tweets;
if (entries == null)
{
entries = TwitterFeed.GetTweets(name);
cache.Add(name, entries);
}
return entries;
}
示例3: 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;
}
示例4: 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;
}
示例5: getTweets
Tweets getTweets(string name)
{
DataCache cache = new DataCache();
Tweets entries = Tweets.FromObject(cache.Get(name));
if (entries == null)
{
entries = TwitterFeed.GetTweets(name);
cache.Add(name, entries.GetBytes());
}
return entries;
}
示例6: 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;
}
示例7: GetToken
public Guid GetToken()
{
var mycache = new DataCache();
var cacheObject = mycache.Get(CacheKey);
if (cacheObject == null || string.IsNullOrEmpty(cacheObject.ToString())) return Guid.Empty;
if (cacheObject is Guid) return (Guid) cacheObject;
Guid result;
if (Guid.TryParse(cacheObject.ToString(), out result))
return result;
return Guid.Empty;
}
示例8: 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();
}
示例9: 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);
}
示例10: Index
public ActionResult Index(string name)
{
Stopwatch timer = new Stopwatch();
timer.Start();
DataCache cache = new DataCache();
Tweets entries = cache.Get(name) as Tweets;
if (entries == null)
{
entries = TwitterFeed.GetTweets(name);
cache.Add(name, entries);
mClient.Send(new BrokeredMessage(name));
}
timer.Stop();
ViewBag.LoadTime = timer.Elapsed.TotalMilliseconds;
return View(entries);
}
示例11: 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);
}
示例12: updateHotTopics
void updateHotTopics(string name)
{
DataCache cache = new DataCache();
var tweets = cache.Get(name) as Tweets;
if (tweets != null)
{
string pattern = "(#|@)[a-zA-Z0-9_]{1,15}";
Regex regx = new Regex(pattern);
CloudTable table = getCloudTable();
foreach (var tweet in tweets.Items)
{
string date = DateTime.Now.ToString("yyyy-MM-dd");
foreach (var match in regx.Matches(tweet.text))
{
string matchString = match.ToString().Substring(1);
TableOperation retrieveOperation = TableOperation.Retrieve<TopicEntity>
(date, matchString);
TableResult retrievedResult = table.Execute(retrieveOperation);
TopicEntity updateEntity = (TopicEntity)retrievedResult.Result;
if (updateEntity != null)
{
updateEntity.Mentions += 1;
TableOperation updateOperation = TableOperation.Replace(updateEntity);
table.Execute(updateOperation);
}
else
{
TopicEntity entity = new TopicEntity(date, matchString);
TableOperation insertOperation = TableOperation.Insert(entity);
table.Execute(insertOperation);
}
}
}
}
}
示例13: 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;
}
}
示例14: GetInfo
public object GetInfo(DataCache _cache, string key)
{
return _cache.Get(key);
}
示例15: CacheDemo
public ActionResult CacheDemo()
{
var cache = new DataCache();
ViewBag.CacheValue = cache.Get("key");
return View();
}