ehcache代码应用
CacheConfiguration fee = new CacheConfiguration("fooCache", 100000) .overflowToDisk(true) .eternal(true) .diskPersistent(false) .transactionalMode("LOCAL") // Tx set programatically .copyOnWrite(true) .copyOnRead(true) .diskStorePath("D:/temp"); Configuration config = new Configuration(); FactoryConfiguration factoryConfigforpeerprovider = new FactoryConfiguration(); factoryConfigforpeerprovider.setClass("net.sf.ehcache.distribution.RMICacheManagerPeerProviderFactory"); factoryConfigforpeerprovider.setProperties("peerDiscovery=automatic, multicastGroupAddress=230.0.0.1,multicastGroupPort=4446, timeToLive=32"); config.addCacheManagerPeerProviderFactory(factoryConfigforpeerprovider); // Configuration for PeerProvider FactoryConfiguration factoryConfigforpeerlistener = new FactoryConfiguration(); factoryConfigforpeerlistener.setClass("net.sf.ehcache.distribution.RMICacheManagerPeerListenerFactory"); factoryConfigforpeerlistener.setProperties("port=40001,socketTimeoutMillis=20000"); config.addCacheManagerPeerListenerFactory(factoryConfigforpeerlistener); FactoryConfiguration factoryConfig = new FactoryConfiguration(); factoryConfig.setClass("net.sf.ehcache.distribution.RMICacheReplicatorFactory"); factoryConfig.setProperties("replicateAsynchronously=true, replicatePuts=false, replicateUpdates=true, replicateUpdatesViaCopy=false, replicateRemovals=true"); //config.addCacheManagerEventListenerFactory(factoryConfig);//Configuration for Replicator CacheManager manager = new CacheManager(config); Cache testCache = new Cache(fee); manager.addCache(testCache);?
?