public ActionResult <CategoryDto> CreateCategory(CategoryDto category) { try { var c = _categoryService.Create(new Category { Id = category.Id, Name = category.Name }); category.Id = c.Id; _cacheStorage.Remove(CacheKeys.AllCategories.ToString()); } catch (DbUpdateException ex) { if (ex?.InnerException?.Message != null) { return(BadRequest(ex?.InnerException?.Message)); } else { return(BadRequest(ex?.Message)); } } return(CreatedAtAction(nameof(GetCategory), new { id = category.Id }, category)); }
/// <summary> /// Clears the specified type from cache so it will be evaluated. /// </summary> /// <param name="type">The type.</param> /// <exception cref="ArgumentNullException">The <paramref name="type"/> is <c>null</c>.</exception> public void Clear(Type type) { Argument.IsNotNull("type", type); lock (_lock) { _fieldsToSerializeCache.Remove(type); _catelPropertiesToSerializeCache.Remove(type); _regularPropertiesToSerializeCache.Remove(type); var key1 = GetCacheKey(type, true); var key2 = GetCacheKey(type, false); _catelPropertyNamesCache.Remove(key1); _catelPropertyNamesCache.Remove(key2); _catelPropertiesCache.Remove(key1); _catelPropertiesCache.Remove(key2); _regularPropertyNamesCache.Remove(type); _regularPropertiesCache.Remove(type); _fieldNamesCache.Remove(type); _fieldsCache.Remove(type); _serializerModifierCache.Remove(type); _serializationModifierDefinitionsPerTypeCache.Remove(type); _serializationModifiersPerTypeCache.Remove(type); } CacheInvalidated?.Invoke(this, new CacheInvalidatedEventArgs(type)); }
public void RemoveGroup(string group) { Tuple <object, HashSet <string> > tuple; if (groups.ContainsKey(group) && groups.TryGetValue(group, out tuple)) { lock (tuple.Item1) { foreach (var key in tuple.Item2) { repo.Remove(key); } } } }
void IScavengingAlgorithm.Execute() { long storageSize = cacheStorage.Size; if (maxCacheStorageSize > 0 && storageSize >= maxCacheStorageSize) { GXLogging.Debug(log, "Start LruScavenging.Execute, maxCacheStorageSize '", () => maxCacheStorageSize + "',storageSize='" + storageSize + "'"); while (storageSize >= maxCacheStorageSize) { string key = GetLruItem(); cacheStorage.Remove(key); if (cacheMetadata != null) { lock (cacheMetadata) { cacheMetadata.Remove(key); } } cachingService.ClearKey(key); lock (itemsLastUsed) { itemsLastUsed.Remove(key); } storageSize = cacheStorage.Size; } } }
protected void TeamSelectedIndexChanged(object o, EventArgs e) { _cache.Remove(SecurityContextManager.Current.CurrentUser.ID.ToString() + "_CommentsFeed"); if (ddlTeams.SelectedIndex > 0) { SecurityContextManager.Current.CurrentTeamID = Convert.ToInt16(ddlTeams.SelectedValue); LoadComments(); ddlCommentFor.LoadUsers(); } else { SecurityContextManager.Current.CurrentTeamID = null; LoadComments(); ddlCommentFor.LoadUsers(); } }
private void MonitorForExpirations() { int checkIntervalInSeconds; int checkIntervalInMilliseconds; int counter; string key; List <string> expiredItems = new List <string>(); checkIntervalInSeconds = 10; checkIntervalInMilliseconds = checkIntervalInSeconds * CONVERT_TO_MILLISECONDS_VALUE; GXLogging.Debug(log, "Start MonitorForExpirations loop "); while (true) { // The use of enumerations is not a thread safe operation lock (itemsExpiration) { // Iterate over the expirations list and // check for expired items foreach (DictionaryEntry dictionary in itemsExpiration) { ICacheItemExpiration exp = (ICacheItemExpiration)dictionary.Value; if (exp.HasExpired()) { key = dictionary.Key.ToString(); expiredItems.Add(key); } } } for (counter = 0; counter < expiredItems.Count; counter++) { cacheStorage.Remove(expiredItems[counter].ToString()); RemoveItem(expiredItems[counter].ToString()); } expiredItems.Clear(); Thread.Sleep(checkIntervalInMilliseconds); } }
public void Delete(DomainType aggregate) { repository.Delete(aggregate); //удаляем указатель CachedCollection.RemovePointer(GetItemCachedKey(aggregate)); Store(CachedCollectionKey, cachedCollection); //удаляем из кеша сам объект cacheStorage.Remove(GetItemCachedKey(aggregate)); }
/// <summary> /// Remove a entrada associada com a chave informada. /// </summary> /// <param name="key">Chave da entrada que será removida.</param> /// <param name="removalReason"></param> /// <param name="isUserOperation"></param> /// <param name="operationContext"></param> /// <returns></returns> internal override CacheEntry RemoveInternal(object key, ItemRemoveReason removalReason, bool isUserOperation, OperationContext operationContext) { if (_cacheStore == null) { throw new InvalidOperationException(); } CacheEntry entry = (CacheEntry)_cacheStore.Remove(key); if ((entry != null) && (_evictionPolicy != null)) { _evictionPolicy.Remove(key, entry.EvictionHint); } return(entry); }
/// <summary> /// Removes the object and key pair from the cache. The key is specified as parameter. /// Moreover it take a removal reason and a boolean specifying if a notification should /// be raised. /// </summary> /// <param name="key">key of the entry.</param> /// <param name="removalReason">reason for the removal.</param> /// <param name="notify">boolean specifying to raise the event.</param> /// <returns>item value</returns> internal override CacheEntry RemoveInternal(object key, ItemRemoveReason removalReason, bool isUserOperation, OperationContext operationContext) { if (ServerMonitor.MonitorActivity) { ServerMonitor.LogClientActivity("LocalCache.Remove", ""); } if (_cacheStore == null) { throw new InvalidOperationException(); } CacheEntry e = (CacheEntry)_cacheStore.Remove(key); if (e != null) { if (_evictionPolicy != null && e.EvictionHint != null) { _evictionPolicy.Remove(key, e.EvictionHint); } if (_notifyCacheFull) { _notifyCacheFull = false; } } if (_context.PerfStatsColl != null) { if (_evictionPolicy != null) { _context.PerfStatsColl.SetEvictionIndexSize((long)_evictionPolicy.IndexInMemorySize); } if (_context.ExpiryMgr != null) { _context.PerfStatsColl.SetExpirationIndexSize((long)_context.ExpiryMgr.IndexInMemorySize); } } return(e); }
/// <summary> /// Ensures that the specified theme is loaded. /// </summary> /// <param name="resourceUri">The resource URI.</param> public static void EnsureThemeIsLoaded(Uri resourceUri) { EnsureThemeIsLoaded(resourceUri, () => { var application = Application.Current; if (application is null) { return(false); } var value = ThemeLoadedCache.GetFromCacheOrFetch(resourceUri, () => ContainsDictionary(application.Resources, resourceUri)); // CTL-893: don't store "false" values, we are only interested in cached "true" values if (!value) { ThemeLoadedCache.Remove(resourceUri); } return(value); }); }
public string CreateComment(Comment comment) { comment.AccountID = SecurityContextManager.Current.CurrentAccount.ID; comment.ChangedBy = ((Person)SecurityContextManager.Current.CurrentUser).ID; comment.DateCreated = DateTime.Now; comment.EnteredBy = ((Person)SecurityContextManager.Current.CurrentUser).ID; comment.LastUpdated = DateTime.Now; comment.FollowUpDate = null; _commentServices.Save(comment); var c = comment; var a = new Activity(); a.AccountID = c.AccountID; a.ActivityType = (int)ActivityType.COMMENT; a.DateCreated = DateTime.Now; a.PerformedBy = c.EnteredBy; a.PerformedFor = c.EnteredFor; a.URL = "/Comments/" + c.ID.ToString(); new ActivityServices().Save(a); IdeaSeed.Core.Data.NHibernate.NHibernateSessionManager.Instance.CloseSession(); if (c.CommentType == -1 || c.CommentType == 1) { var nc = new CommentServices().GetByID(c.ID); if (new TeamMemberServices().GetByPersonIDTeamID(c.EnteredFor, c.TeamID).RecievesNotifications) { EmailHelper.SendNewCommentNotification(nc); } } _cache.Remove(SecurityContextManager .Current .CurrentUser.ID.ToString() + "_CommentsFeed"); return("1:Comment Successfully Created!:/Comments"); }
/// <summary> /// Clears the specified type from cache so it will be evaluated. /// </summary> /// <param name="type">The type.</param> /// <exception cref="ArgumentNullException">The <paramref name="type"/> is <c>null</c>.</exception> public void Clear(Type type) { Argument.IsNotNull("type", type); lock (_lock) { _fieldsToSerializeCache.Remove(type); _propertiesToSerializeCache.Remove(type); _catelPropertyNamesCache.Remove(type); _catelPropertiesCache.Remove(type); _regularPropertyNamesCache.Remove(type); _regularPropertiesCache.Remove(type); _fieldNamesCache.Remove(type); _fieldsCache.Remove(type); _serializerModifierCache.Remove(type); _serializationModifiersPerTypeCache.Remove(type); } CacheInvalidated.SafeInvoke(this, new CacheInvalidatedEventArgs(type)); }
/// <summary> /// 移除缓存 /// </summary> /// <param name="key"></param> public static void Remove(String key) { cacheInstance.Remove(key); }
public void Logout(string email) { _cache.Remove(email); }
/// <inheritdoc /> public async Task Remove(string key) { await _cacheStorage.Remove(key).ConfigureAwait(false); }
public void SavePost(Core.Domain.Project.Project post) { _repository.Save(post); _uow.Commit(); _cache.Remove(RAM.Core.ResourceStrings.Cache_Projects); }
public void SaveBanner(Banner banner) { _repository.Save(banner); _uow.Commit(); _cache.Remove(RAM.Core.ResourceStrings.Cache_Banners); }
private void SaveProfile() { string url = ""; if (CurrentProfile != null) { if (((Person)SecurityContextManager.Current.CurrentUser).RoleID == (int)SecurityRole.ADMIN) { CurrentProfile.IsActive = cbIsActive.Checked; CurrentProfile.IsManager = cbIsManager.Checked; CurrentProfile.HireDate = (DateTime)tbHireDate.SelectedDate; if (tbTerminationDate.SelectedDate != null) { CurrentProfile.TerminationDate = (DateTime)tbTerminationDate.SelectedDate; } CurrentProfile.RoleID = Convert.ToInt16(ddlSecurityRole.SelectedValue); } url = SecurityContextManager.Current.CurrentURL; } else { CurrentProfile = new Person(); CurrentProfile.DateCreated = DateTime.Now; CurrentProfile.AcceptedTerms = false; CurrentProfile.AccountID = ((Person)SecurityContextManager.Current.CurrentUser).AccountID; if (((Person)SecurityContextManager.Current.CurrentUser).RoleID == (int)SecurityRole.ADMIN) { CurrentProfile.IsActive = cbIsActive.Checked; CurrentProfile.IsManager = cbIsManager.Checked; CurrentProfile.HireDate = (DateTime)tbHireDate.SelectedDate; if (tbTerminationDate.SelectedDate != null) { CurrentProfile.TerminationDate = (DateTime)tbTerminationDate.SelectedDate; } CurrentProfile.RoleID = Convert.ToInt16(ddlSecurityRole.SelectedValue); } CurrentProfile.EnteredBy = SecurityContextManager.Current.CurrentUser.ID; CurrentProfile.DateCreated = DateTime.Now; CurrentProfile.AvatarPath = ResourceStrings.DefaultImageNotFound; } CurrentProfile.ChangedBy = SecurityContextManager.Current.CurrentUser.ID; CurrentProfile.LastUpdated = DateTime.Now; CurrentProfile.FirstName = tbFirstName.Text; CurrentProfile.LastName = tbLastName.Text; CurrentProfile.Email = tbEmail.Text; //CurrentProfile.DateAcceptedTerms = DateTime.Now; CurrentProfile.Title = tbTitle.Text; CurrentProfile.Birthdate = (DateTime)tbBirthdate.SelectedDate; CurrentProfile.DepartmentID = Convert.ToInt16(ddlDepartments.SelectedValue); CurrentProfile.ManagerID = Convert.ToInt16(ddlManager.SelectedValue); if (!string.IsNullOrEmpty(tbPassword.Text)) { CurrentProfile.Password = IdeaSeed.Core.SecurityUtils.GetMd5Hash(tbPassword.Text); } CurrentProfile.PasswordAnswer = tbSecurityAnswer.Text; CurrentProfile.PasswordQuestion = tbSecurityQuestion.Text; CurrentProfile.FacebookPath = tbFacebookURL.Text; CurrentProfile.TwitterPath = tbTwitterURL.Text; CurrentProfile.LinkedInPath = tbLinkedInURL.Text; CurrentProfile.ReceiveCommentNotifications = cbReceivesNotifications.Checked; if (radAsyncUpload.UploadedFiles.Count > 0) { UploadedFile file = radAsyncUpload.UploadedFiles[0]; string filePath = CurrentProfile.Email + "_" + file.FileName.Replace(" ", "_").Replace("-", "_").Replace(",", "_"); string thumbPath = "thumb_" + filePath; file.SaveAs(Server.MapPath(ConfigurationManager.AppSettings["AVATARIMAGEPATH"]) + filePath, true); CurrentProfile.AvatarPath = filePath; //MemoryStream imgStream = new MemoryStream(); //Bitmap newimg = new Bitmap(Server.MapPath(CurrentProfile.AvatarPath)); //newimg.Save(imgStream, ImageFormat.Jpeg); byte[] data = HRR.Web.Utils.ImageResize.ResizeFromImagePath(50, ResourceStrings.AvatarBasePath + CurrentProfile.AvatarPath, CurrentProfile.AvatarPath); MemoryStream imgStream = new MemoryStream(data); System.Drawing.Image img = System.Drawing.Image.FromStream(imgStream); img.Save(Server.MapPath(ConfigurationManager.AppSettings["AVATARIMAGEPATH"] + thumbPath)); } new PersonServices().Save(CurrentProfile); _cache.Remove(SecurityContextManager .Current .CurrentUser.ID.ToString() + "_DepartmentsList"); if (SecurityContextManager.Current.CurrentUser.ID == CurrentProfile.ID) { SecurityContextManager.Current.CurrentUser.AvatarPath = CurrentProfile.AvatarPath; } //SecurityContextManager.Current.CurrentProfile = CurrentProfile; //SecurityContextManager.Current.CurrentUser = CurrentProfile; if (string.IsNullOrEmpty(url)) { url = "/People/" + CurrentProfile.Email + "/Edit"; } Response.Redirect(url); }
private void ClearResponseCache(SurveyResponse surveyResponse) { var cacheKey = string.Format("Survey.{0}.{1}", surveyResponse.SurveyName, surveyResponse.UserID); _cacheStorage.Remove(cacheKey); }
public void Remove(string key) { _cache.Remove(key); }
public void SavePost(Blog post) { _repository.Save(post); _uow.Commit(); _cache.Remove(RAM.Core.ResourceStrings.Cache_BlogPosts); }