package com.DatingSocial.server;
import java.util.Collections;
import javax.cache.Cache;
import javax.cache.CacheException;
import javax.cache.CacheManager;
import com.google.appengine.api.datastore.Blob;
public class MemCache<K, V>
{
private Cache cache = null;
private MemCache() throws CacheException
{
cache = CacheManager.getInstance().getCacheFactory().createCache
(Collections.EMPTY_MAP);
}
public static <K, V> MemCache<K, V> getInstance() throws
CacheException
{
return new MemCache<K, V>();
}
public void put(K key, V value)
{
cache.put(key, value);
}
@SuppressWarnings("unchecked")
public V get(K key)
{
return (V)cache.get(key);
}
@SuppressWarnings("unchecked")
public void cachePicture(Long userId, Integer pictureNumber, Blob
pictureBytes)
{
if(pictureBytes != null)
{
cache.put((V)userId.toString() + "-picture-" +
pictureNumber.toString(), pictureBytes.getBytes());
}
}
@SuppressWarnings("unchecked")
public V readCachedPicture(Long userId, Integer pictureNumber)
{
String key = userId.toString() + "-picture-" +
pictureNumber.toString
();
return this.get((K)key);
}
}
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---