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

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

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

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.wso2.org.apache.shindig/shindig-common

 @Override
 protected synchronized boolean removeEldestEntry(Map.Entry<K, V> eldest) {
  return size() > capacity;
 }
}
origin: org.wso2.org.apache.shindig/shindig-common

 @Test
 public void exceededCapacityRemoved() {
  for (int i = 0; i < TEST_CAPACITY + 1; ++i) {
   cache.addElement(Integer.toString(i), Integer.toString(i));
  }
  assertEquals(TEST_CAPACITY, cache.size());
  assertEquals(TEST_CAPACITY, cache.getSize());
  assertEquals(TEST_CAPACITY, cache.getCapacity());
  assertNull(cache.getElement("0"));
 }
}
origin: com.lmco.shindig/shindig-common

@Test
public void normalCapacityOk() {
 for (int i = 0; i < TEST_CAPACITY; ++i) {
  cache.addElement(Integer.toString(i), Integer.toString(i));
 }
 assertEquals(TEST_CAPACITY, cache.size());
 assertEquals(TEST_CAPACITY, cache.getSize());
 assertEquals(TEST_CAPACITY, cache.getCapacity());
 assertEquals("0", cache.getElement("0"));
}
origin: com.lmco.shindig/shindig-common

 @Test
 public void exceededCapacityRemoved() {
  for (int i = 0; i < TEST_CAPACITY + 1; ++i) {
   cache.addElement(Integer.toString(i), Integer.toString(i));
  }
  assertEquals(TEST_CAPACITY, cache.size());
  assertEquals(TEST_CAPACITY, cache.getSize());
  assertEquals(TEST_CAPACITY, cache.getCapacity());
  assertNull(cache.getElement("0"));
 }
}
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: org.apache.shindig/shindig-common

 @Override
 protected synchronized boolean removeEldestEntry(Map.Entry<K, V> eldest) {
  return size() > capacity;
 }
}
origin: apache/shindig

 @Test
 public void exceededCapacityRemoved() {
  for (int i = 0; i < TEST_CAPACITY + 1; ++i) {
   cache.addElement(Integer.toString(i), Integer.toString(i));
  }
  assertEquals(TEST_CAPACITY, cache.size());
  assertEquals(TEST_CAPACITY, cache.getSize());
  assertEquals(TEST_CAPACITY, cache.getCapacity());
  assertNull(cache.getElement("0"));
 }
}
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: org.gatein.shindig/shindig-common

 @Override
 protected synchronized boolean removeEldestEntry(Map.Entry<K, V> eldest) {
  return size() > capacity;
 }
}
origin: org.gatein.shindig/shindig-common

@Test
public void normalCapacityOk() {
 for (int i = 0; i < TEST_CAPACITY; ++i) {
  cache.addElement(Integer.toString(i), Integer.toString(i));
 }
 assertEquals(TEST_CAPACITY, cache.size());
 assertEquals(TEST_CAPACITY, cache.getSize());
 assertEquals(TEST_CAPACITY, cache.getCapacity());
 assertEquals("0", cache.getElement("0"));
}
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

 @Override
 protected synchronized boolean removeEldestEntry(Map.Entry<K, V> eldest) {
  return size() > capacity;
 }
}
origin: org.gatein.shindig/shindig-common

 @Test
 public void exceededCapacityRemoved() {
  for (int i = 0; i < TEST_CAPACITY + 1; ++i) {
   cache.addElement(Integer.toString(i), Integer.toString(i));
  }
  assertEquals(TEST_CAPACITY, cache.size());
  assertEquals(TEST_CAPACITY, cache.getSize());
  assertEquals(TEST_CAPACITY, cache.getCapacity());
  assertNull(cache.getElement("0"));
 }
}
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: apache/shindig

 @Override
 protected synchronized boolean removeEldestEntry(Map.Entry<K, V> eldest) {
  return size() > capacity;
 }
}
origin: org.wso2.org.apache.shindig/shindig-common

@Test
public void normalCapacityOk() {
 for (int i = 0; i < TEST_CAPACITY; ++i) {
  cache.addElement(Integer.toString(i), Integer.toString(i));
 }
 assertEquals(TEST_CAPACITY, cache.size());
 assertEquals(TEST_CAPACITY, cache.getSize());
 assertEquals(TEST_CAPACITY, cache.getCapacity());
 assertEquals("0", cache.getElement("0"));
}
origin: org.apache.shindig/shindig-common

@Before
public void setUp() throws Exception {
 timeSource = new FakeTimeSource(0);
 cache = new LruCache<String, String>(5);
}
origin: org.gatein.shindig/shindig-common

public long getSize() {
 return size();
}
origin: org.apache.shindig/shindig-common

@Test
public void normalCapacityOk() {
 for (int i = 0; i < TEST_CAPACITY; ++i) {
  cache.addElement(Integer.toString(i), Integer.toString(i));
 }
 assertEquals(TEST_CAPACITY, cache.size());
 assertEquals(TEST_CAPACITY, cache.getSize());
 assertEquals(TEST_CAPACITY, cache.getCapacity());
 assertEquals("0", cache.getElement("0"));
}
org.apache.shindig.common.cacheLruCache

Javadoc

A basic LRU cache. Prefer using EhCache for most purposes to this class.

Most used methods

  • <init>
  • size
  • addElement
  • getCapacity
  • getElement
  • getSize

Popular in Java

  • Updating database using SQL prepared statement
  • onCreateOptionsMenu (Activity)
  • notifyDataSetChanged (ArrayAdapter)
  • scheduleAtFixedRate (Timer)
  • ObjectMapper (com.fasterxml.jackson.databind)
    ObjectMapper provides functionality for reading and writing JSON, either to and from basic POJOs (Pl
  • Component (java.awt)
    A component is an object having a graphical representation that can be displayed on the screen and t
  • Kernel (java.awt.image)
  • JarFile (java.util.jar)
    JarFile is used to read jar entries and their associated data from jar files.
  • DataSource (javax.sql)
    An interface for the creation of Connection objects which represent a connection to a database. This
  • Logger (org.slf4j)
    The org.slf4j.Logger interface is the main user entry point of SLF4J API. It is expected that loggin
  • Github Copilot 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