@Before public void setUp() throws JAXBException { cacheManager = new MemcachedManager(); cacheManager.setDefaultTtl(60); // default time to live cacheManager.setHosts("localhost:11211"); // list of memcached hosts cacheManager.setCacheTranscoder(CacheTranscoder.KRYO); cacheManager.setKryo(new Kryo()); }
@Test public void testCacheManagerNonSerializable() throws InterruptedException, CacheException { DummyNonSerializable d = new DummyNonSerializable( "Mickey_laskmdkasmdlaksmdkasdasdasdasdasdasdasasmdlaskmdlaksmdlaskmdaklsmmdaskmldasklmdsakasoijdasoidjasidjaoisjdoasijdsaoidjaoisdj", "Donald_askdadasdasdasdasdasdsadasdasdmaklsmdlaksmdalskmdaasdassdslkmdaslkdmaslkdmaskldmaklsmdalskmdalksmdlaksdmalskdmalskdmalskdmalksdmalskdmalskdmalskdmalkdm"); String key = "plutinho"; Cache<String, DummyNonSerializable> cache = cacheManager.getCache("test1"); cache.put(key, d, 60); long init = System.currentTimeMillis(); for (int i = 1; i <= 1000; i++) { DummyNonSerializable iamBack = cache.get(key); assertNotNull(iamBack); /*System.out.println("size: " + cache.size()); System.out.println(iamBack);*/ } System.out.println("Time(Non Serializable): " + (System.currentTimeMillis() - init)); }