• New Feature
  • Status: Closed
  • 2 Major
  • Resolution: Fixed
  • Reporter: steve
  • October 02, 2009
  • 0
  • Watchers: 0
  • July 27, 2012
  • October 05, 2009

Description

http://www.ehcache.org/documentation/samples.html

here is a quick and dirty one I did but feel free to ignore it and do your own.

package org.sharrissf.samples;

import net.sf.ehcache.Cache; import net.sf.ehcache.CacheManager; import net.sf.ehcache.Element;

public class MyFirstEhcacheSample { CacheManager cacheManager = new CacheManager(“src/ehcache.xml”);

public MyFirstEhcacheSample() \{
	Cache cache = cacheManager.getCache("testCache");
	int cacheSize = cache.getKeys().size();
	cache.put(new Element("" + cacheSize, cacheSize));
	for (Object key : cache.getKeys()) \{
		System.out.println("Key:" + key);
	\}
\}

public static void main(String[] args) throws Exception \{
	new MyFirstEhcacheSample();
\} \}

<?xml version=”1.0” encoding=”UTF-8”?>

Comments

gluck 2009-10-05

Done.