private void RemoveCacheByGroup(int userID, int groupID) { string cacheKey = string.Format(cacheKey_ByGroup, userID, groupID); CacheUtil.RemoveBySearch(string.Format(cacheKey_EmoticonPagedRoot, groupID));//清除已分页的本组缓存 CacheUtil.Remove(cacheKey); }
public bool SaveTags(IEnumerable <string> tagNames, TagType type, int targetID, int operatorID) { if (tagNames != null) { TagCollection tags = new TagCollection(); foreach (string tagName in tagNames) { string t = tagName.Trim(); if (string.IsNullOrEmpty(t)) { continue; } Tag tag = new Tag(); tag.Name = t; tag.IsLock = false; tags.Add(tag); } string cacheKey = GetCacheKeyForUserTags(type, operatorID); CacheUtil.Remove(cacheKey); return(SaveTags(tags, type, targetID)); } return(false); }
/// <summary> /// 批量删除表情 /// </summary> /// <param name="userID">用户ID</param> /// <param name="groupID"></param> /// <param name="emoticonsIdentities">要删除的ID</param> /// <returns></returns> public void DeleteEmoticons(int userID, int groupID, IEnumerable <int> emoticonIds) { if (ValidateUtil.HasItems <int>(emoticonIds)) { List <string> canDeleteFiles = EmoticonDao.Instance.DeleteEmoticons(userID, groupID, emoticonIds); CacheUtil.RemoveBySearch(string.Format(cacheKey_EmoticonPagedRoot, groupID)); CacheUtil.Remove(string.Format(cacheKey_EmoticonUserGroups, userID)); DeleteEmoticonFiles(canDeleteFiles); } }
/// <summary> /// ����ɾ��ָ���û���ָ��Ŀ¼�е��ļ��� /// </summary> /// <param name="userID">��ǰ�û�ID��</param> /// <param name="directoryID">��Ŀ¼ID��</param> /// <param name="diskFileIdentities">�ļ�ID�б��</param> /// <returns>����<see cref="DeleteStatus"/>��</returns> public DeleteStatus DeleteDiskFiles(int userID, int directoryID, IEnumerable <int> diskFileIds) { //List<string> needDeleteFileIds; DeleteStatus status = DiskDao.Instance.DeleteDiskFiles(userID, directoryID, diskFileIds); if (status == DeleteStatus.Success) { CacheUtil.Remove(string.Format(cacheKey_directory, userID, directoryID)); //FileManager.DeleteFiles(needDeleteFileIds); } return(status); }
public bool IgnoreDenouncings(int operatorID, int[] denouncingIDs) { if (ManagePermission.Can(operatorID, BackendPermissions.Action.Manage_Report) == false) { ThrowError(new NoPermissionIgnoreDenouncingError()); return false; } DenouncingDao.Instance.IgnoreDenouncings(denouncingIDs); CacheUtil.Remove("Denouncing/Count"); return true; }
/// <summary> /// 移除用户的表情分组缓存 /// </summary> /// <param name="userID"></param> private void RemoveCachedUserEmoticonGroups(int userID) { string cacheKey = string.Format(cacheKey_EmoticonUserGroups, userID); EmoticonGroupCollection cachedGroups; if (CacheUtil.TryGetValue <EmoticonGroupCollection>(cacheKey, out cachedGroups)) { CacheUtil.Remove(cacheKey); foreach (EmoticonGroup group in cachedGroups) { CacheUtil.Remove(string.Format(cacheKey_EmoticonGroup, group.GroupID)); } } }
/*----------------------3.0------------------------------*/ public bool RenameEmoticonShortcut(int userID, int groupID, List <int> emoticonIDs, List <string> newShortcuts) { //替换|为空 string sortcurString = StringUtil.Join(newShortcuts); if (sortcurString.IndexOf('"') > -1 || sortcurString.IndexOf('<') > -1 || sortcurString.IndexOf('>') > -1) { ThrowError(new InvalidEmoticonShortcutError()); return(false); } Dictionary <string, int> temp = new Dictionary <string, int>(new DictionaryIgnoreCase()); for (int i = 0; i < newShortcuts.Count; i++) { newShortcuts[i] = newShortcuts[i].Replace("|", ""); if (newShortcuts[i].Length > 15) { newShortcuts[i] = newShortcuts[i].Substring(0, 15); } if (!temp.ContainsKey(newShortcuts[i])) { temp.Add(newShortcuts[i], emoticonIDs[i]); } else { if (newShortcuts[i] != string.Empty) { return(false); } } } bool status = EmoticonDao.Instance.RenameEmoticonShortcut(userID, groupID, emoticonIDs, newShortcuts); //缓存更新 if (status) { foreach (int i in emoticonIDs) { CacheUtil.Remove(string.Format(cacheKey_Emoticon, i)); } RemoveCacheByGroup(userID, groupID); } return(status); }
private static void ClearForumThreadsCache(string cacheKey, int forumID) { List <string> cacheKeys = null; if (s_ForumCacheKeys != null && s_ForumCacheKeys.TryGetValue(forumID, out cacheKeys)) { if (cacheKeys.Contains(cacheKey)) { cacheKeys.Remove(cacheKey); } } ThreadCollectionV5 threads; if (CacheUtil.TryGetValue <ThreadCollectionV5>(cacheKey, out threads)) { CacheUtil.Remove(cacheKey); UpdateAllCachedThreadsRemoveThreads(threads, forumID, null); } }
public bool CreateDenouncing(int operatorID, int targetID, int targetUserID, DenouncingType type, string content, string createIP) { if (targetID <= 0) { ThrowError(new InvalidParamError("targetID")); return false; } if (StringUtil.GetByteCount("content") > Consts.Report_Length) { Context.ThrowError(new InvalidReportLengthError("content", content, Consts.Report_Length)); return false; } DenouncingDao.Instance.CreateDenouncing(operatorID, targetID, targetUserID, type, content, createIP); CacheUtil.Remove("Denouncing/Count"); return true; }
/// <summary> /// 移除版块的主题列表缓存 同时更新主题缓存 /// </summary> /// <param name="forumID"></param> /// <param name="threadIDs">要更新的主题缓存,如果没有传NULL</param> public static void ClearForumCache(int forumID, IEnumerable <int> threadIDs) { if (s_ForumCacheKeys == null) { return; } List <string> tempKeys; if (s_ForumCacheKeys.TryGetValue(forumID, out tempKeys)) { List <string> keys = new List <string>(tempKeys); ThreadCollectionV5 cachedThreads = new ThreadCollectionV5(); foreach (string key in keys) { ThreadCollectionV5 tempThreads; if (CacheUtil.TryGetValue <ThreadCollectionV5>(key, out tempThreads)) { foreach (BasicThread thread in tempThreads) { if (cachedThreads.ContainsKey(thread.ThreadID) == false) { cachedThreads.Add(thread); } } CacheUtil.Remove(key); } } if (cachedThreads.Count > 0) { UpdateAllCachedThreadsRemoveThreads(cachedThreads, null, null); } } if (threadIDs != null) { UpdateCache(threadIDs); } }
public EmoticonGroup GetEmoticonGroup(int userID, int groupID) { string cacheKey = string.Format(cacheKey_EmoticonUserGroups, userID); EmoticonGroupCollection groups; if (CacheUtil.TryGetValue <EmoticonGroupCollection>(cacheKey, out groups)) { if (groups.GetValue(groupID) != null) { return(groups.GetValue(groupID)); } } else { EmoticonGroup group = EmoticonDao.Instance.GetEmoticonGroup(userID, groupID); //并不进行单个分组缓存, 通常是用户的全部分组缓存 CacheUtil.Remove(cacheKey); return(group); } return(null); }
/// <summary> /// 创建许多表情 /// </summary> /// <param name="emoticon"></param> /// <returns></returns> public void CreateEmoticons(int userID, EmoticonCollection emoticons) { if (!CanUseEmoticon(userID)) { ThrowError(new NoPermissionUseEmoticonError()); return; } List <int> removedCackes = new List <int>(); foreach (Emoticon emote in emoticons) { if (!removedCackes.Contains(emote.GroupID)) { CacheUtil.RemoveBySearch(string.Format(cacheKey_EmoticonPagedRoot, emote.GroupID)); removedCackes.Add(emote.GroupID); } emote.UserID = userID; } CacheUtil.Remove(string.Format(cacheKey_EmoticonUserGroups, userID)); EmoticonDao.Instance.CreateEmoticons(emoticons); }
private void ClearTopUserShowsCache() { CacheUtil.Remove(showUsersKey); }
private void RemoveCachedTargetUserImpressionRecordsTotalCount(int targetUserID) { CacheUtil.Remove(GetCacheKeyForTargetUserImpressionRecordsTotalCount(targetUserID)); }
private void ClearClubMemberStatusCache(int userID, int clubID) { CacheUtil.Remove(GetCacheKeyForClubMemberStatus(userID, clubID)); }
private void ClearClubCache(int clubID) { CacheUtil.Remove(GetCacheKeyForClub(clubID)); }