[jbosscache-commits] JBoss Cache SVN: r7013 - benchmarks/benchmark-fwk/trunk/cache-products/terracotta-2.5.0/src/org/cachebench/cachewrappers.

jbosscache-commits at lists.jboss.org jbosscache-commits at lists.jboss.org
Sat Oct 25 19:25:14 EDT 2008


Author: manik.surtani at jboss.com
Date: 2008-10-25 19:25:14 -0400 (Sat, 25 Oct 2008)
New Revision: 7013

Modified:
   benchmarks/benchmark-fwk/trunk/cache-products/terracotta-2.5.0/src/org/cachebench/cachewrappers/TerracottaWrapper.java
Log:
more accurate wrapper

Modified: benchmarks/benchmark-fwk/trunk/cache-products/terracotta-2.5.0/src/org/cachebench/cachewrappers/TerracottaWrapper.java
===================================================================
--- benchmarks/benchmark-fwk/trunk/cache-products/terracotta-2.5.0/src/org/cachebench/cachewrappers/TerracottaWrapper.java	2008-10-25 23:23:15 UTC (rev 7012)
+++ benchmarks/benchmark-fwk/trunk/cache-products/terracotta-2.5.0/src/org/cachebench/cachewrappers/TerracottaWrapper.java	2008-10-25 23:25:14 UTC (rev 7013)
@@ -16,7 +16,7 @@
 public class TerracottaWrapper implements CacheWrapper
 {
    // Since terracotta 
-   private final Map cache = new HashMap();
+   private final Map<List<String>, Map> sessionCaches = new HashMap<List<String>, Map>();
 
    public void init(Map parameters) throws Exception
    {
@@ -33,14 +33,16 @@
 
    public void tearDown() throws Exception
    {
-      synchronized (cache)
-      {
-         cache.clear();
-      }
+      empty();
    }
 
    public void put(List<String> path, Object key, Object value) throws Exception
    {
+      Map cache;
+      synchronized (sessionCaches)
+      {
+         cache = sessionCaches.get(path);
+      }
       synchronized (cache)
       {
          cache.put(key, value);
@@ -49,6 +51,11 @@
 
    public Object get(List<String> path, Object key) throws Exception
    {
+      Map cache;
+      synchronized (sessionCaches)
+      {
+         cache = sessionCaches.get(path);
+      }
       synchronized (cache)
       {
          return cache.get(key);
@@ -57,9 +64,16 @@
 
    public void empty() throws Exception
    {
-      synchronized (cache)
+      synchronized (sessionCaches)
       {
-         cache.clear();
+         for (Map cache : sessionCaches.values())
+         {
+            synchronized (cache)
+            {
+               cache.clear();
+            }
+         }
+         sessionCaches.clear();
       }
    }
 
@@ -70,10 +84,19 @@
 
    public String getInfo()
    {
-      synchronized (cache)
+      int sz = 0;
+      synchronized (sessionCaches)
       {
-         return "There are " + cache.size() + " objects in cache";
+         for (Map cache : sessionCaches.values())
+         {
+            synchronized (cache)
+            {
+               sz += cache.size();
+            }
+         }
       }
+
+      return "There are " + sz + " objects in cache";
    }
 
 }




More information about the jbosscache-commits mailing list