Permalink
Browse files

Added examples directory with simple example.

  • Loading branch information...
1 parent 1083c2d commit a3c7f22778322c8c855339d1f6a790b9d1460577 Jason Voegele committed Oct 28, 2010
Showing with 57 additions and 0 deletions.
  1. +44 −0 examples/ehcache.xml
  2. +13 −0 examples/jruby-ehcache.rb
View
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:noNamespaceSchemaLocation="../../main/config/ehcache.xsd">
+
+ <!-- Disable for test ehcache.xml. Should go to the same place. -->
+ <diskStore path="java.io.tmpdir"/>
+
+ <cacheManagerPeerProviderFactory class="net.sf.ehcache.distribution.RMICacheManagerPeerProviderFactory"
+ properties="peerDiscovery=automatic, multicastGroupAddress=230.0.0.1, multicastGroupPort=4446, timeToLive=0"/>
+
+
+ <cacheManagerPeerListenerFactory class="net.sf.ehcache.distribution.RMICacheManagerPeerListenerFactory"
+ properties="hostName=, port=, socketTimeoutMillis="/>
+
+
+ <defaultCache
+ name="default"
+ maxElementsInMemory="10"
+ eternal="false"
+ timeToIdleSeconds="5"
+ timeToLiveSeconds="10"
+ overflowToDisk="true"
+ />
+
+
+ <!-- Sample cache named sampleCache1 -->
+ <cache name="sampleCache1"
+ maxElementsInMemory="10000"
+ maxElementsOnDisk="1000"
+ eternal="false"
+ timeToIdleSeconds="360"
+ timeToLiveSeconds="1000"
+ overflowToDisk="true">
+ </cache>
+
+ <!-- Sample cache named sampleCache2. Is eternal. Is diskPersistent but does not overflow to disk -->
+ <cache name="sampleCache2"
+ maxElementsInMemory="1000"
+ eternal="true"
+ overflowToDisk="false"
+ diskPersistent="true"
+ />
+</ehcache>
View
@@ -0,0 +1,13 @@
+require 'ehcache'
+
+manager = Ehcache::CacheManager.new
+cache = manager.cache
+
+cache.put("answer", "42", {:ttl => 120})
+answer = cache.get("answer")
+puts "Answer: #{answer}"
+
+question = cache.get("question") || 'unknown'
+puts "Question: #{question}"
+
+manager.shutdown

0 comments on commit a3c7f22

Please sign in to comment.