Skip to content

Instantly share code, notes, and snippets.

@crised
Created February 12, 2013 16:13
Show Gist options
  • Save crised/4770990 to your computer and use it in GitHub Desktop.
Save crised/4770990 to your computer and use it in GitHub Desktop.
package web;
import org.infinispan.Cache;
import org.infinispan.manager.DefaultCacheManager;
import org.infinispan.manager.EmbeddedCacheManager;
import org.jboss.logging.Logger;
import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
import javax.inject.Named;
import java.util.concurrent.TimeUnit;
@Named
@RequestScoped
public class Pagination {
@Resource(lookup = "java:jboss/infinispan/container/appcache")
private EmbeddedCacheManager cacheManager;
Cache cache;
static final Logger log = Logger.getLogger(Pagination.class);
int counter;
@PostConstruct
public void method() {
cache = cacheManager.getCache("pagination",false);
cache.put(0, "Hello");
}
public void log(){
if(cache.get(0)==null){
cache.put(0, "Refreshed: " + counter + "times");
counter++;
}
log.info(cache.get(0));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment