Skip to content

Instantly share code, notes, and snippets.

@abhirockzz
Last active February 3, 2016 06:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save abhirockzz/80de4398286f92748212 to your computer and use it in GitHub Desktop.
Save abhirockzz/80de4398286f92748212 to your computer and use it in GitHub Desktop.
Cache Injection snippet
@Path("{jsrNum}")
public class JavaEE8Resource {
@Inject
@CacheContext("jsrinfocache")
Cache<String, String> cache;
.....
@GET
public Response getinfo(@PathParam("jsrNum") String jsrNum) {
String resp = null;
if(!cache.containsKey(jsrNum)){
//do something !
}else{
//use the cache.... !
}
return Response.ok(resp).build();
}
.....
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment