Skip to content

Instantly share code, notes, and snippets.

@edpichler
Created February 8, 2011 10:44
Show Gist options
  • Save edpichler/816260 to your computer and use it in GitHub Desktop.
Save edpichler/816260 to your computer and use it in GitHub Desktop.
package com.edpichler.bovespa.process.appengine;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import net.sf.jsr107cache.CacheException;
import net.sf.jsr107cache.CacheFactory;
import net.sf.jsr107cache.CacheManager;
import com.edpichler.bovespa.business.IQuoteCache;
import com.edpichler.bovespa.persistent.ICodeQuote;
import com.edpichler.bovespa.persistent.impl.StockQuote;
import com.edpichler.osgi.bovespa.quote.BovespaProvider;
import com.edpichler.osgi.bovespa.quote.IQuote;
import com.google.appengine.api.memcache.jsr107cache.GCacheFactory;
public class AppengineMemCacheMap implements IQuoteCache {
private Cache cache;
public AppengineMemCacheMap() {
Map props = new HashMap();
props.put(GCacheFactory.EXPIRATION_DELTA, 60);// seconds
try {
CacheFactory cacheFactory = CacheManager.getInstance()
.getCacheFactory();
cache = cacheFactory.createCache(props);
}
@Override
public void updateQuote(ICodeQuote stock) {
cache.put(stock.getCodigo(), stock);
}
...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment