cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r1462986 - /cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/cache/NestedQueryCache.java
Date Sun, 31 Mar 2013 15:27:09 GMT
Author: aadamchik
Date: Sun Mar 31 15:27:09 2013
New Revision: 1462986

URL: http://svn.apache.org/r1462986
Log:
shortening cache key prefix of the nested cache...

this should somwhat speed up nested cache key handling...
fewer chars to process when building the key,
fewer chars to scan during comparisons

Modified:
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/cache/NestedQueryCache.java

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/cache/NestedQueryCache.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/cache/NestedQueryCache.java?rev=1462986&r1=1462985&r2=1462986&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/cache/NestedQueryCache.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/cache/NestedQueryCache.java
Sun Mar 31 15:27:09 2013
@@ -32,14 +32,19 @@ import org.apache.cayenne.query.QueryMet
 import org.apache.cayenne.reflect.ClassDescriptor;
 
 /**
- * A {@link QueryCache} wrapper that introduces a key namespace on top of a delegate
- * shared cache. This way multiple cache users can share the same underlying cache without
- * a possibility of key conflicts, yet refresh the cache groups in a coordinated fashion.
+ * A {@link QueryCache} wrapper that introduces a key namespace on top of a
+ * delegate shared cache. This way multiple cache users can share the same
+ * underlying cache without a possibility of key conflicts, yet refresh the
+ * cache groups in a coordinated fashion.
  * 
  * @since 3.0
  */
 public class NestedQueryCache implements QueryCache {
 
+    // the idea is to be something short (to speed up comparisons), but clear
+    // and unlikely to create a conflict with application cache keys...
+    // fully-qualified class name that we used before was a bit too long
+    private static final String NAMESPACE_PREXIX = "#nested-";
     private static volatile int currentId;
 
     protected QueryCache delegate;
@@ -55,12 +60,12 @@ public class NestedQueryCache implements
 
     public NestedQueryCache(QueryCache delegate) {
         this.delegate = delegate;
-        this.namespace = getClass().getName() + nextInt() + ":";
+        this.namespace = NAMESPACE_PREXIX + nextInt() + ":";
     }
 
     /**
-     * Returns the actual implementation of the query cache that is wrapped by this
-     * NestedQueryCache.
+     * Returns the actual implementation of the query cache that is wrapped by
+     * this NestedQueryCache.
      */
     public QueryCache getDelegate() {
         return delegate;
@@ -70,7 +75,8 @@ public class NestedQueryCache implements
      * Clears the underlying shared cache.
      */
     public void clear() {
-        // seems pretty evil - it clears the keys that do not belong to our subset of the
+        // seems pretty evil - it clears the keys that do not belong to our
+        // subset of the
         // cache
         delegate.clear();
     }
@@ -84,7 +90,7 @@ public class NestedQueryCache implements
     public List get(QueryMetadata metadata) {
         return delegate.get(qualifiedMetadata(metadata));
     }
-    
+
     @SuppressWarnings("rawtypes")
     public void put(QueryMetadata metadata, List results) {
         delegate.put(qualifiedMetadata(metadata), results);



Mime
View raw message