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

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

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

origin: com.lmco.shindig/shindig-common

LruCacheProvider createProvider(final String name, final String capacity, int defaultCapacity) {
 Module module = new AbstractModule() {
  @Override
  public void configure() {
   binder().bindConstant()
     .annotatedWith(Names.named("shindig.cache.lru." + name + ".capacity"))
     .to(capacity);
  }
 };
 Injector injector = Guice.createInjector(module);
 return new LruCacheProvider(injector, defaultCapacity);
}
origin: org.apache.shindig/shindig-common

 @SuppressWarnings("unchecked")
 public <K, V> Cache<K, V> createCache(String name) {
  int capacity = getCapacity(Preconditions.checkNotNull(name));
  Cache<K, V> cache = (Cache<K, V>) caches.get(name);
  if (cache == null) {
   if (LOG.isLoggable(Level.FINE)) {
    LOG.fine("Creating cache named " + name);
   }
   cache = new LruCache<K, V>(capacity);
   caches.put(name, cache);
  }
  return cache;
 }
}
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.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.gatein.shindig/shindig-common

LruCacheProvider createProvider(final String name, final String capacity, int defaultCapacity) {
 Module module = new AbstractModule() {
  @Override
  public void configure() {
   binder().bindConstant()
     .annotatedWith(Names.named("shindig.cache.lru." + name + ".capacity"))
     .to(capacity);
  }
 };
 Injector injector = Guice.createInjector(module);
 return new LruCacheProvider(injector, defaultCapacity);
}
origin: org.wso2.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: com.lmco.shindig/shindig-common

 @SuppressWarnings("unchecked")
 public <K, V> Cache<K, V> createCache(String name) {
  int capacity = getCapacity(Preconditions.checkNotNull(name));
  Cache<K, V> cache = (Cache<K, V>) caches.get(name);
  if (cache == null) {
   if (LOG.isLoggable(Level.FINE)) {
    LOG.fine("Creating cache named " + name);
   }
   cache = new LruCache<K, V>(capacity);
   caches.put(name, cache);
  }
  return cache;
 }
}
origin: org.apache.shindig/shindig-common

LruCacheProvider createProvider(final String name, final String capacity, int defaultCapacity) {
 Module module = new AbstractModule() {
  @Override
  public void configure() {
   binder().bindConstant()
     .annotatedWith(Names.named("shindig.cache.lru." + name + ".capacity"))
     .to(capacity);
  }
 };
 Injector injector = Guice.createInjector(module);
 return new LruCacheProvider(injector, defaultCapacity);
}
origin: org.wso2.org.apache.shindig/shindig-gadgets

@Test
public void testInvalidateUrl() throws Exception {
 cache.addResponse(new HttpRequest(URI), CACHEABLE);
 assertEquals(1, cacheProvider.createCache(DefaultHttpCache.CACHE_NAME).getSize());
 service.invalidateApplicationResources(
   ImmutableSet.of(URI),
   appxToken);
 assertEquals(0, cacheProvider.createCache(DefaultHttpCache.CACHE_NAME).getSize());
}
origin: apache/shindig

 @SuppressWarnings("unchecked")
 public <K, V> Cache<K, V> createCache(String name) {
  int capacity = getCapacity(Preconditions.checkNotNull(name));
  Cache<K, V> cache = (Cache<K, V>) caches.get(name);
  if (cache == null) {
   if (LOG.isLoggable(Level.FINE)) {
    LOG.fine("Creating cache named " + name);
   }
   cache = new LruCache<K, V>(capacity);
   caches.put(name, cache);
  }
  return cache;
 }
}
origin: org.wso2.org.apache.shindig/shindig-common

LruCacheProvider createProvider(final String name, final String capacity, int defaultCapacity) {
 Module module = new AbstractModule() {
  @Override
  public void configure() {
   binder().bindConstant()
     .annotatedWith(Names.named("shindig.cache.lru." + name + ".capacity"))
     .to(capacity);
  }
 };
 Injector injector = Guice.createInjector(module);
 return new LruCacheProvider(injector, defaultCapacity);
}
origin: org.apache.shindig/shindig-gadgets

@Test
public void testInvalidateUrl() throws Exception {
 cache.addResponse(new HttpRequest(URI), CACHEABLE);
 assertEquals(1, cacheProvider.createCache(DefaultHttpCache.CACHE_NAME).getSize());
 service.invalidateApplicationResources(
   ImmutableSet.of(URI),
   appxToken);
 assertEquals(0, cacheProvider.createCache(DefaultHttpCache.CACHE_NAME).getSize());
}
origin: org.gatein.shindig/shindig-common

 @SuppressWarnings("unchecked")
 public <K, V> Cache<K, V> createCache(String name) {
  int capacity = getCapacity(Preconditions.checkNotNull(name));
  Cache<K, V> cache = (Cache<K, V>) caches.get(name);
  if (cache == null) {
   if (LOG.isLoggable(Level.FINE)) {
    LOG.fine("Creating cache named " + name);
   }
   cache = new LruCache<K, V>(capacity);
   caches.put(name, cache);
  }
  return cache;
 }
}
origin: apache/shindig

LruCacheProvider createProvider(final String name, final String capacity, int defaultCapacity) {
 Module module = new AbstractModule() {
  @Override
  public void configure() {
   binder().bindConstant()
     .annotatedWith(Names.named("shindig.cache.lru." + name + ".capacity"))
     .to(capacity);
  }
 };
 Injector injector = Guice.createInjector(module);
 return new LruCacheProvider(injector, defaultCapacity);
}
origin: com.lmco.shindig/shindig-gadgets

@Test
public void testInvalidateUrl() throws Exception {
 cache.addResponse(new HttpRequest(URI), CACHEABLE);
 assertEquals(1, cacheProvider.createCache(DefaultHttpCache.CACHE_NAME).getSize());
 service.invalidateApplicationResources(
   ImmutableSet.of(URI),
   appxToken);
 assertEquals(0, cacheProvider.createCache(DefaultHttpCache.CACHE_NAME).getSize());
}
origin: org.wso2.org.apache.shindig/shindig-common

 @SuppressWarnings("unchecked")
 public <K, V> Cache<K, V> createCache(String name) {
  int capacity = getCapacity(Preconditions.checkNotNull(name));
  Cache<K, V> cache = (Cache<K, V>) caches.get(name);
  if (cache == null) {
   if (LOG.isLoggable(Level.FINE)) {
    LOG.fine("Creating cache named " + name);
   }
   cache = new LruCache<K, V>(capacity);
   caches.put(name, cache);
  }
  return cache;
 }
}
origin: com.lmco.shindig/shindig-common

@Test
public void defaultCapacityForNamedCache() throws Exception {
 LruCacheProvider provider = new LruCacheProvider(10);
 assertEquals(10, getCache(provider, "foo").capacity);
}
origin: com.lmco.shindig/shindig-gadgets

@Test
public void testFetchContentWithMarker() throws Exception {
 oauth.httpResponse = CACHEABLE;
 // First entry added to cache is unmarked
 HttpResponse httpResponse = requestPipeline.execute(signedRequest);
 assertEquals(CACHEABLE, httpResponse);
 assertEquals(1, cacheProvider.createCache(DefaultHttpCache.CACHE_NAME).getSize());
 // Invalidate content for OwnerX. Next entry will have owner mark
 service.invalidateUserResources(ImmutableSet.of("OwnerX"), appxToken);
 oauth.httpResponse = new HttpResponseBuilder(CACHEABLE).setResponseString("NEWCONTENT1").
   create();
 httpResponse = requestPipeline.execute(signedRequest);
 assertEquals("NEWCONTENT1", httpResponse.getResponseAsString());
 assertEquals("o=1;", httpResponse.getHeader(DefaultInvalidationService.INVALIDATION_HEADER));
 assertEquals(1, cacheProvider.createCache(DefaultHttpCache.CACHE_NAME).getSize());
 // Invalidate content for ViewerX. Next entry will have both owner and viewer mark
 service.invalidateUserResources(ImmutableSet.of("ViewerX"), appxToken);
 oauth.httpResponse = new HttpResponseBuilder(CACHEABLE).setResponseString("NEWCONTENT2").
   create();
 httpResponse = requestPipeline.execute(signedRequest);
 assertEquals("NEWCONTENT2", httpResponse.getResponseAsString());
 assertEquals("o=1;v=2;",
   httpResponse.getHeader(DefaultInvalidationService.INVALIDATION_HEADER));
 assertEquals(1, cacheProvider.createCache(DefaultHttpCache.CACHE_NAME).getSize());
}
origin: com.lmco.shindig/shindig-gadgets

@Before
public void setUp() throws Exception {
 cajaCssParser = new CajaCssParser();
 cajaCssParser.setCacheProvider(new LruCacheProvider(10));
}
origin: org.apache.shindig/shindig-gadgets

@Test
public void testFetchContentWithMarker() throws Exception {
 oauth.httpResponse = CACHEABLE;
 // First entry added to cache is unmarked
 HttpResponse httpResponse = requestPipeline.execute(signedRequest);
 assertEquals(CACHEABLE, httpResponse);
 assertEquals(1, cacheProvider.createCache(DefaultHttpCache.CACHE_NAME).getSize());
 // Invalidate content for OwnerX. Next entry will have owner mark
 service.invalidateUserResources(ImmutableSet.of("OwnerX"), appxToken);
 oauth.httpResponse = new HttpResponseBuilder(CACHEABLE).setResponseString("NEWCONTENT1").
   create();
 httpResponse = requestPipeline.execute(signedRequest);
 assertEquals("NEWCONTENT1", httpResponse.getResponseAsString());
 assertEquals("o=1;", httpResponse.getHeader(DefaultInvalidationService.INVALIDATION_HEADER));
 assertEquals(1, cacheProvider.createCache(DefaultHttpCache.CACHE_NAME).getSize());
 // Invalidate content for ViewerX. Next entry will have both owner and viewer mark
 service.invalidateUserResources(ImmutableSet.of("ViewerX"), appxToken);
 oauth.httpResponse = new HttpResponseBuilder(CACHEABLE).setResponseString("NEWCONTENT2").
   create();
 httpResponse = requestPipeline.execute(signedRequest);
 assertEquals("NEWCONTENT2", httpResponse.getResponseAsString());
 assertEquals("o=1;v=2;",
   httpResponse.getHeader(DefaultInvalidationService.INVALIDATION_HEADER));
 assertEquals(1, cacheProvider.createCache(DefaultHttpCache.CACHE_NAME).getSize());
}
org.apache.shindig.common.cacheLruCacheProvider

Javadoc

A cache provider that always produces LRU caches. LRU cache sizes can be configured by specifying property names in the form shindig.cache.lru..capacity=foo The default value is expected under shindig.cache.lru.default.capacity An in memory LRU cache only scales so far. For a production-worthy cache, use EhCacheCacheProvider.

Most used methods

  • <init>
  • getCapacity
  • createCache

Popular in Java

  • Running tasks concurrently on multiple threads
  • scheduleAtFixedRate (ScheduledExecutorService)
  • findViewById (Activity)
  • onRequestPermissionsResult (Fragment)
  • Arrays (java.util)
    This class contains various methods for manipulating arrays (such as sorting and searching). This cl
  • Calendar (java.util)
    Calendar is an abstract base class for converting between a Date object and a set of integer fields
  • Comparator (java.util)
    A Comparator is used to compare two objects to determine their ordering with respect to each other.
  • JLabel (javax.swing)
  • JList (javax.swing)
  • IOUtils (org.apache.commons.io)
    General IO stream manipulation utilities. This class provides static utility methods for input/outpu
  • CodeWhisperer alternatives
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