title: sample example for JCS
body: <p>I am implementing JCS for the first time.</p>
  
  <p>My requirement :
  I have one java class with a main method in which i am storing some data in the cache.</p>
  
  <p>I have second java class with a main method from which i am retrieving from the disk cache which i had stored using the first java class.</p>
  
  <p>Please note: 
  1. I want to use disk cache(Of JCS).
  2. I want to retrieve the data from different JVM.
  3. When i run the first Java class main method, i should store the data in the disk cache and when i run the second java class main method, i want to retrieve the data from the cache which is stored in the disk using the first java class main method.</p>
  
  <p>class 1: main method..</p>
  
  <pre><code>public static void main(String[] args) {
  //   Initialize the JCS object and get an instance of the default cache region
      try {
          JCS cache = JCS.getInstance("default");
  
      String key = "key0";
      String value = "value0";
  
      cache.put(key, value);
      cache.put("vasu","dev");
  
  
      } catch (CacheException e) {
          e.printStackTrace();
      }
  }
  </code></pre>
  
  <p>class2: main method</p>
  
  <pre><code>public static void main (String asd[]){
      try {
          JCS cache = JCS.getInstance("default");
  
  
      String cachedData = (String)cache.get("vasu");
  
  
  //   Check if the retrieval worked
      if (cachedData != null) {
        // The cachedData is valid and can be used
        System.out.println("Valid cached Data: " + cachedData);
      }
      else
           System.out.println("Invalid cached Data: ");
  
      } catch (CacheException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
      }
      catch (Exception e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
      }
  }
  </code></pre>
  
  <p>cache.ccf:</p>
  
  <pre><code>jcs.default=DISK_REGION
  jcs.default.cacheattributes=org.apache.jcs.engine.CompositeCacheAttributes
  jcs.default.cacheattributes.MaxObjects=1000
  jcs.default.cacheattributes.MemoryCacheName=org.apache.jcs.engine.memory.lru.LRUMemoryCache
  jcs.default.elementattributes.IsEternal=false
  jcs.default.elementattributes.MaxLifeSeconds=3600
  jcs.default.elementattributes.IdleTime=1800
  jcs.default.elementattributes.IsSpool=true
  jcs.default.elementattributes.IsRemote=true
  jcs.default.elementattributes.IsLateral=true
  
  jcs.region.OUR_REGION=DISK_REGION
  jcs.region.OUR_REGION.cacheattributes=org.apache.jcs.engine.CompositeCacheAttributes
  jcs.region.OUR_REGION.cacheattributes.MaxObjects=1000
  jcs.region.OUR_REGION.cacheattributes.MemoryCacheName=org.apache.jcs.engine.memory.lru.LRUMemoryCache
  jcs.region.OUR_REGION.cacheattributes.UseMemoryShrinker=true
  jcs.region.OUR_REGION.cacheattributes.MaxMemoryIdleTimeSeconds=3600
  jcs.region.OUR_REGION.cacheattributes.ShrinkerIntervalSeconds=60
  jcs.region.OUR_REGION.cacheattributes.MaxSpoolPerRun=500
  jcs.region.OUR_REGION.elementattributes=org.apache.jcs.engine.ElementAttributes
  jcs.region.OUR_REGION.elementattributes.IsEternal=false
  
  jcs.auxiliary.DISK_REGION=org.apache.jcs.auxiliary.disk.indexed.IndexedDiskCacheFactory
  jcs.auxiliary.DISK_REGION.attributes=org.apache.jcs.auxiliary.disk.indexed.IndexedDiskCacheAttributes
  jcs.auxiliary.DISK_REGION.attributes.DiskPath=c:/jcs/disk_region
  jcs.auxiliary.DISK_REGION.attributes.MaxPurgatorySize=10000
  jcs.auxiliary.DISK_REGION.attributes.MaxKeySize=10000
  jcs.auxiliary.DISK_REGION.attributes.OptimizeAtRemoveCount=300000
  jcs.auxiliary.DISK_REGION.attributes.MaxRecycleBinSize=7500
  </code></pre>