All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.ibole.infrastructure.cache.ehcache.EhcacheWrapper Maven / Gradle / Ivy

The newest version!
package com.github.ibole.infrastructure.cache.ehcache;

import com.github.ibole.infrastructure.cache.CacheWrapper;

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

/*********************************************************************************************
 * .
 * 
 * 
 * 

Copyright 2016, iBole Inc. All rights reserved. * *

. *

*********************************************************************************************/ public class EhcacheWrapper implements CacheWrapper { private final String cacheName; private final CacheManager cacheManager; public EhcacheWrapper(final String cacheName, final CacheManager cacheManager) { this.cacheName = cacheName; this.cacheManager = cacheManager; } public void put(final K key, final V value) { getCache().put(new Element(key, value)); } @SuppressWarnings("unchecked") public V get(final K key) { Element element = getCache().get(key); if (element != null) { return (V) element.getValue(); } return null; } public Ehcache getCache() { return cacheManager.getEhcache(cacheName); } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy