2 Replies Latest reply on Aug 5, 2004 11:09 AM by bisla

    CacheLoader

    bisla

      Hi,
      I'm running to some problem and here's whats happening
      I create TreeCache object and a CacheLoader which just has printlns in them.
      so when u do cache.get() if the object is there in cache it would be returned if it isn't then the cache would ask the CacheLoader to load it Right ?? well that's what I'm cheching and it looks like i'm not getting any results(as non of the sys outs inthe CacheLoader not printed). I think i'm doing something wrong and so here's the code....

      public class CacheWrapperTest extends Thread implements TreeCacheListener{
      ....
      ..
       public CacheWrapperTest() {
       TreeCache cache = new TreeCache();
       cache.setCacheLoader(new MyCacheLoader());
       cache.create();
       cache.start();
       }
      
       public void run() {
       try
       {
       cache.addTreeCacheListener(this);
       cache.put("/a/b/c", "name", "Kunal Bisla");
      
       while (true)
       {
       Node node = cache.get("/a/b/c");
       System.out.println("/a/b/c " + node);
       >>>>>node = cache.get("/aaaa/aaab/aaaab");
       // Now at the above node is not present
       //one should see the system outs in the CacheLoader on the console.
       System.out.println("/a/b/b : " + node);
       sleep(10000);
       }
       }
       catch (Exception e)
       {
       e.printStackTrace();
       }
      
       publilc static void main(String args[])
       {
       new CacheWrapperTest().start();
       }
       }
      

      when the >>> line gets invoked I think that the
      CacheLoader's load method would be called to
      load the item from underlying persistence store. But
      actually this isn't happening.
      I'm running this as a standalone application, should
      that be a problem.
      Any pointer would be appreciated.
      Thanks,
      Kunal