[Notice] Announcing the End of Demo Server [Read me]
doortts doortts 2017-01-13
CacheStore: Support more cache cases
@5d11a8b3698225c765fb63e9643282d010e9d8d9
app/controllers/ProjectApp.java
--- app/controllers/ProjectApp.java
+++ app/controllers/ProjectApp.java
@@ -66,6 +66,8 @@
 
 import static play.data.Form.form;
 import static play.libs.Json.toJson;
+import static utils.CacheStore.getProjectCacheKey;
+import static utils.CacheStore.projectMap;
 import static utils.LogoUtil.*;
 import static utils.TemplateHelper.*;
 
@@ -197,6 +199,7 @@
 
         saveProjectMenuSetting(project);
         Watch.watch(project.asResource());
+        projectMap.put(getProjectCacheKey(project.owner, project.name), project.id);
 
         return redirect(routes.ProjectApp.project(project.owner, project.name));
     }
app/controllers/UserApp.java
--- app/controllers/UserApp.java
+++ app/controllers/UserApp.java
@@ -622,8 +622,9 @@
                     user.save();
                 }
                 return ok(edit_token.render(userForm, user));
-            default:
             case PROFILE:
+                return ok(edit.render(userForm, user));
+            default:
                 return ok(edit.render(userForm, user));
         }
     }
@@ -700,6 +701,7 @@
 
         Email.deleteOtherInvalidEmails(user.email);
         user.update();
+        CacheStore.yonaUsers.put(user.id, user);
         return redirect(routes.UserApp.userInfo(user.loginId, DEFAULT_GROUP, DAYS_AGO, DEFAULT_SELECTED_TAB));
     }
 
app/models/Project.java
--- app/models/Project.java
+++ app/models/Project.java
@@ -54,6 +54,8 @@
 import java.util.List;
 import java.util.Set;
 
+import static utils.CacheStore.getProjectCacheKey;
+import static utils.CacheStore.projectMap;
 import static utils.HttpUtil.decodeUrlString;
 
 @Entity
@@ -169,7 +171,7 @@
     }
 
     public static Project findByOwnerAndProjectName(String loginId, String projectName) {
-        String key = decodeUrlString(loginId) + ":" + decodeUrlString(projectName);
+        String key = getProjectCacheKey(loginId, projectName);
         Long projectId = CacheStore.projectMap.get(key);
         if(projectId == null || projectId == 0){
             Project project= find.where().ieq("owner", decodeUrlString(loginId)).ieq("name", decodeUrlString(projectName))
@@ -649,6 +651,7 @@
     @Override
     public void delete() {
         CacheStore.refreshProjectMap();
+        projectMap.remove(getProjectCacheKey(this.owner, this.name));
         deleteProjectTransfer();
         deleteFork();
         deleteCommentThreads();
app/models/User.java
--- app/models/User.java
+++ app/models/User.java
@@ -785,6 +785,7 @@
     public void removeEmail(Email email) {
         emails.remove(email);
         email.delete();
+        CacheStore.yonaUsers.put(this.id, this);
     }
 
     public void visits(Project project) {
Add a comment
List