db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kahat...@apache.org
Subject svn commit: r572693 - /db/derby/code/trunk/java/engine/org/apache/derby/impl/services/cache/ConcurrentCache.java
Date Tue, 04 Sep 2007 14:47:27 GMT
Author: kahatlen
Date: Tue Sep  4 07:47:27 2007
New Revision: 572693

URL: http://svn.apache.org/viewvc?rev=572693&view=rev
Log:
DERBY-2911 (partial) Implemented CacheManager.values() for ConcurrentCache

Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/impl/services/cache/ConcurrentCache.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/services/cache/ConcurrentCache.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/services/cache/ConcurrentCache.java?rev=572693&r1=572692&r2=572693&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/services/cache/ConcurrentCache.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/services/cache/ConcurrentCache.java
Tue Sep  4 07:47:27 2007
@@ -21,6 +21,7 @@
 
 package org.apache.derby.impl.services.cache;
 
+import java.util.ArrayList;
 import java.util.Collection;
 import java.util.concurrent.ConcurrentHashMap;
 import org.apache.derby.iapi.error.StandardException;
@@ -401,8 +402,28 @@
         return allRemoved;
     }
 
-    public Collection values() {
-        // TODO
-        return null;
+    /**
+     * Return a collection view of all the <code>Cacheable</code>s in the
+     * cache. There is no guarantee that the objects in the collection can be
+     * accessed in a thread-safe manner once this method has returned, so it
+     * should only be used for diagnostic purposes. (Currently, it is only used
+     * by the <code>StatementCache</code> VTI.)
+     *
+     * @return a collection view of the objects in the cache
+     */
+    public Collection<Cacheable> values() {
+        ArrayList<Cacheable> values = new ArrayList<Cacheable>();
+        for (CacheEntry entry : cache.values()) {
+            entry.lock();
+            try {
+                Cacheable c = entry.getCacheable();
+                if (c != null) {
+                    values.add(c);
+                }
+            } finally {
+                entry.unlock();
+            }
+        }
+        return values;
     }
 }



Mime
View raw message