roller-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From agillil...@apache.org
Subject svn commit: r395303 - /incubator/roller/branches/roller-newbackend/src/org/roller/business/hibernate/HibernateUserManagerImpl.java
Date Wed, 19 Apr 2006 16:31:11 GMT
Author: agilliland
Date: Wed Apr 19 09:31:09 2006
New Revision: 395303

URL: http://svn.apache.org/viewcvs?rev=395303&view=rev
Log:
make sure that items are removed from cache mapping is a lookup appears to be stale.


Modified:
    incubator/roller/branches/roller-newbackend/src/org/roller/business/hibernate/HibernateUserManagerImpl.java

Modified: incubator/roller/branches/roller-newbackend/src/org/roller/business/hibernate/HibernateUserManagerImpl.java
URL: http://svn.apache.org/viewcvs/incubator/roller/branches/roller-newbackend/src/org/roller/business/hibernate/HibernateUserManagerImpl.java?rev=395303&r1=395302&r2=395303&view=diff
==============================================================================
--- incubator/roller/branches/roller-newbackend/src/org/roller/business/hibernate/HibernateUserManagerImpl.java
(original)
+++ incubator/roller/branches/roller-newbackend/src/org/roller/business/hibernate/HibernateUserManagerImpl.java
Wed Apr 19 09:31:09 2006
@@ -50,7 +50,10 @@
     
     private HibernatePersistenceStrategy strategy = null;
     
+    // cached mapping of weblogHandles -> weblogIds
     private Map weblogHandleToIdMap = new Hashtable();
+    
+    // cached mapping of userNames -> userIds
     private Map userNameToIdMap = new Hashtable();
     
     
@@ -380,12 +383,16 @@
         // NOTE: if we ever allow changing handles then this needs updating
         if(this.weblogHandleToIdMap.containsKey(handle)) {
             
-            log.debug("weblogHandleToId CACHE HIT - "+handle);
-            
             WebsiteData weblog = this.getWebsite((String) this.weblogHandleToIdMap.get(handle));
-            if(weblog != null && 
-                    (enabled == null || enabled.equals(weblog.getEnabled()))) {
-                return weblog;
+            if(weblog != null) {
+                // only return weblog if enabled status matches
+                if(enabled == null || enabled.equals(weblog.getEnabled())) {
+                    log.debug("weblogHandleToId CACHE HIT - "+handle);
+                    return weblog;
+                }
+            } else {
+                // mapping hit with lookup miss?  mapping must be old, remove it
+                this.weblogHandleToIdMap.remove(handle);
             }
         }
         
@@ -466,12 +473,16 @@
         // NOTE: if we ever allow changing usernames then this needs updating
         if(this.userNameToIdMap.containsKey(userName)) {
             
-            log.debug("userNameToIdMap CACHE HIT - "+userName);
-            
             UserData user = this.getUser((String) this.userNameToIdMap.get(userName));
-            if(user != null && 
-                    (enabled == null || enabled.equals(user.getEnabled()))) {
-                return user;
+            if(user != null) {
+                // only return the user if the enabled status matches
+                if(enabled == null || enabled.equals(user.getEnabled())) {
+                    log.debug("userNameToIdMap CACHE HIT - "+userName);
+                    return user;
+                }
+            } else {
+                // mapping hit with lookup miss?  mapping must be old, remove it
+                this.userNameToIdMap.remove(userName);
             }
         }
         



Mime
View raw message