congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
Cache
Code IndexAdd Tabnine to your IDE (free)

How to use
Cache
in
org.apache.shindig.common.cache

Best Java code snippets using org.apache.shindig.common.cache.Cache (Showing top 20 results out of 315)

origin: org.apache.shindig/shindig-gadgets

@Override
protected void addResponseImpl(String key, HttpResponse response) {
 cache.addElement(key, response);
}
origin: org.apache.shindig/shindig-gadgets

@Override
protected HttpResponse getResponseImpl(String key) {
 return cache.getElement(key);
}
origin: org.apache.shindig/shindig-gadgets

 private boolean shouldCache() {
  return parsedCssCache != null && parsedCssCache.getCapacity() != 0;
 }
}
origin: org.apache.shindig/shindig-gadgets

public CssTree.StyleSheet parseDom(String content, Uri source)
  throws GadgetException {
 CssTree.StyleSheet parsedCss = null;
 boolean shouldCache = shouldCache();
 String key = null;
 if (shouldCache) {
  // TODO - Consider using the source if its under a certain size
  key = HashUtil.checksum(content.getBytes());
  parsedCss = parsedCssCache.getElement(key);
 }
 if (parsedCss == null) {
  try {
   parsedCss = parseImpl(content, source);
   if (shouldCache) {
    parsedCssCache.addElement(key, parsedCss);
   }
  } catch (ParseException pe) {
   // Bad input; not server's fault.
   throw new GadgetException(GadgetException.Code.CSS_PARSE_ERROR, pe,
     HttpResponse.SC_BAD_REQUEST);
  }
 }
 if (shouldCache) {
  return (CssTree.StyleSheet)parsedCss.clone();
 }
 return parsedCss;
}
origin: apache/shindig

@Test
public void getNamedCache() throws Exception {
 Cache<String, String> cache = defaultProvider.createCache("testcache");
 Cache<String, String> cache2 = defaultProvider.createCache("testcache");
 Assert.assertNotNull(cache);
 Assert.assertEquals(cache, cache2);
 Assert.assertNull(cache.getElement("test"));
 cache.addElement("test", "value1");
 Assert.assertEquals("value1", cache.getElement("test"));
 cache.removeElement("test");
 Assert.assertNull(cache.getElement("test"));
 Assert.assertEquals(cache.getCapacity(), cache2.getCapacity());
 Assert.assertEquals(cache.getSize(), cache2.getSize());
}
origin: org.apache.shindig/shindig-gadgets

 @Test
 public void removeResponse() {
  HttpRequest request = new HttpRequest(DEFAULT_URI);
  HttpResponse response = new HttpResponse("response");

  String key = httpCache.createKey(request);

  cache.addElement(key, response);

  assertEquals(response, httpCache.removeResponse(request));

  assertEquals(0, cache.getSize());
 }
}
origin: com.lmco.shindig/shindig-gadgets

@Test
public void testInvalidateUsers() throws Exception {
 service.invalidateUserResources(ImmutableSet.of("example.org:1", "example.org:2"),
   appxToken);
 service.invalidateUserResources(ImmutableSet.of("example.org:1", "example.org:2"),
   appyToken);
 assertEquals(4, cacheProvider.createCache(DefaultInvalidationService.CACHE_NAME).getSize());
 assertNotNull(cacheProvider.createCache(DefaultInvalidationService.CACHE_NAME)
   .getElement("INV_TOK:AppX:1"));
 assertNotNull(cacheProvider.createCache(DefaultInvalidationService.CACHE_NAME)
   .getElement("INV_TOK:AppX:2"));
 assertNotNull(cacheProvider.createCache(DefaultInvalidationService.CACHE_NAME)
   .getElement("INV_TOK:AppY:1"));
 assertNotNull(cacheProvider.createCache(DefaultInvalidationService.CACHE_NAME)
   .getElement("INV_TOK:AppY:2"));
}
origin: org.wso2.org.apache.shindig/shindig-gadgets

@Test
public void ignoreCacheDoesNotStore() throws Exception {
 bundleFactory.getBundle(gadgetSpec, new Locale("all", "ALL"), true, ContainerConfig.DEFAULT_CONTAINER, null);
 assertEquals(0, cache.getSize());
}
origin: org.gatein.shindig/shindig-gadgets

 @Override
 protected HttpResponse removeResponseImpl(String key) {
  return cache.removeElement(key);
 }
}
origin: org.gatein.shindig/shindig-gadgets

public List<Object> parse(String content) throws GadgetException {
 List<Object> parsedCss = null;
 boolean shouldCache = shouldCache();
 String key = null;
 if (shouldCache) {
  // TODO - Consider using the source if its under a certain size
  key = HashUtil.checksum(content.getBytes());
  parsedCss = parsedCssCache.getElement(key);
 }
 if (parsedCss == null) {
  parsedCss = parseImpl(content);
  if (shouldCache) {
   parsedCssCache.addElement(key, parsedCss);
  }
 }
 if (shouldCache) {
  List<Object> cloned = Lists.newArrayListWithCapacity(parsedCss.size());
  for (Object o : parsedCss) {
   if (o instanceof ImportDecl) {
    cloned.add(new ImportDecl(((ImportDecl) o).getUri()));
   } else if (o instanceof UriDecl) {
    cloned.add(new UriDecl(((UriDecl) o).getUri()));
   } else {
    cloned.add(o);
   }
  }
  return cloned;
 }
 return parsedCss;
}
origin: org.apache.shindig/shindig-common

@Test
public void getNamedCache() throws Exception {
 Cache<String, String> cache = defaultProvider.createCache("testcache");
 Cache<String, String> cache2 = defaultProvider.createCache("testcache");
 Assert.assertNotNull(cache);
 Assert.assertEquals(cache, cache2);
 Assert.assertNull(cache.getElement("test"));
 cache.addElement("test", "value1");
 Assert.assertEquals("value1", cache.getElement("test"));
 cache.removeElement("test");
 Assert.assertNull(cache.getElement("test"));
 Assert.assertEquals(cache.getCapacity(), cache2.getCapacity());
 Assert.assertEquals(cache.getSize(), cache2.getSize());
}
origin: org.wso2.org.apache.shindig/shindig-gadgets

 @Test
 public void removeResponse() {
  HttpRequest request = new HttpRequest(DEFAULT_URI);
  HttpResponse response = new HttpResponse("response");

  String key = httpCache.createKey(request);

  cache.addElement(key, response);

  assertEquals(response, httpCache.removeResponse(request));

  assertEquals(0, cache.getSize());
 }
}
origin: org.apache.shindig/shindig-gadgets

@Test
public void testInvalidateUsers() throws Exception {
 service.invalidateUserResources(ImmutableSet.of("example.org:1", "example.org:2"),
   appxToken);
 service.invalidateUserResources(ImmutableSet.of("example.org:1", "example.org:2"),
   appyToken);
 assertEquals(4, cacheProvider.createCache(DefaultInvalidationService.CACHE_NAME).getSize());
 assertNotNull(cacheProvider.createCache(DefaultInvalidationService.CACHE_NAME)
   .getElement("INV_TOK:AppX:1"));
 assertNotNull(cacheProvider.createCache(DefaultInvalidationService.CACHE_NAME)
   .getElement("INV_TOK:AppX:2"));
 assertNotNull(cacheProvider.createCache(DefaultInvalidationService.CACHE_NAME)
   .getElement("INV_TOK:AppY:1"));
 assertNotNull(cacheProvider.createCache(DefaultInvalidationService.CACHE_NAME)
   .getElement("INV_TOK:AppY:2"));
}
origin: org.apache.shindig/shindig-gadgets

@Test
public void ignoreCacheDoesNotStore() throws Exception {
 bundleFactory.getBundle(gadgetSpec, new Locale("all", "ALL"), true, ContainerConfig.DEFAULT_CONTAINER, null);
 assertEquals(0, cache.getSize());
}
origin: com.lmco.shindig/shindig-gadgets

 @Override
 protected HttpResponse removeResponseImpl(String key) {
  return cache.removeElement(key);
 }
}
origin: org.apache.shindig/shindig-gadgets

public List<Object> parse(String content) throws GadgetException {
 List<Object> parsedCss = null;
 boolean shouldCache = shouldCache();
 String key = null;
 if (shouldCache) {
  // TODO - Consider using the source if its under a certain size
  key = HashUtil.checksum(content.getBytes());
  parsedCss = parsedCssCache.getElement(key);
 }
 if (parsedCss == null) {
  parsedCss = parseImpl(content);
  if (shouldCache) {
   parsedCssCache.addElement(key, parsedCss);
  }
 }
 if (shouldCache) {
  List<Object> cloned = Lists.newArrayListWithCapacity(parsedCss.size());
  for (Object o : parsedCss) {
   if (o instanceof ImportDecl) {
    cloned.add(new ImportDecl(((ImportDecl) o).getUri()));
   } else if (o instanceof UriDecl) {
    cloned.add(new UriDecl(((UriDecl) o).getUri()));
   } else {
    cloned.add(o);
   }
  }
  return cloned;
 }
 return parsedCss;
}
origin: org.wso2.org.apache.shindig/shindig-common

@Test
public void getNamedCache() throws Exception {
 Cache<String, String> cache = defaultProvider.createCache("testcache");
 Cache<String, String> cache2 = defaultProvider.createCache("testcache");
 Assert.assertNotNull(cache);
 Assert.assertEquals(cache, cache2);
 Assert.assertNull(cache.getElement("test"));
 cache.addElement("test", "value1");
 Assert.assertEquals("value1", cache.getElement("test"));
 cache.removeElement("test");
 Assert.assertNull(cache.getElement("test"));
 Assert.assertEquals(cache.getCapacity(), cache2.getCapacity());
 Assert.assertEquals(cache.getSize(), cache2.getSize());
}
origin: org.apache.shindig/shindig-common

 public void put(String expression, Tree tree) {
  resolvedTreeCache.addElement(expression, tree);
 }
};
origin: org.gatein.shindig/shindig-gadgets

@Override
protected HttpResponse getResponseImpl(String key) {
 return cache.getElement(key);
}
origin: com.lmco.shindig/shindig-gadgets

 @Test
 public void removeResponse() {
  HttpRequest request = new HttpRequest(DEFAULT_URI);
  HttpResponse response = new HttpResponse("response");

  String key = httpCache.createKey(request);

  cache.addElement(key, response);

  assertEquals(response, httpCache.removeResponse(request));

  assertEquals(0, cache.getSize());
 }
}
org.apache.shindig.common.cacheCache

Javadoc

A basic cache interface. If necessary, we can always move to the commons cache for the future.

Most used methods

  • addElement
    Stores an entry into the cache.
  • getElement
    Retrieves an entry for the cache.
  • getCapacity
    Returns the capacity of the cache.
  • getSize
  • removeElement
    Removes an entry from the cache.

Popular in Java

  • Making http post requests using okhttp
  • notifyDataSetChanged (ArrayAdapter)
  • findViewById (Activity)
  • startActivity (Activity)
  • BufferedWriter (java.io)
    Wraps an existing Writer and buffers the output. Expensive interaction with the underlying reader is
  • FileOutputStream (java.io)
    An output stream that writes bytes to a file. If the output file exists, it can be replaced or appen
  • PrintWriter (java.io)
    Wraps either an existing OutputStream or an existing Writerand provides convenience methods for prin
  • BigDecimal (java.math)
    An immutable arbitrary-precision signed decimal.A value is represented by an arbitrary-precision "un
  • Selector (java.nio.channels)
    A controller for the selection of SelectableChannel objects. Selectable channels can be registered w
  • SimpleDateFormat (java.text)
    Formats and parses dates in a locale-sensitive manner. Formatting turns a Date into a String, and pa
  • Top Vim plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now