com.github.ibole.infrastructure.cache.ehcache.EhcacheWrapper Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of infrastructure-all Show documentation
Show all versions of infrastructure-all Show documentation
The all in one project of ibole infrastructure
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