Codota Logo
CacheCleaner
Code IndexAdd Codota to your IDE (free)

How to use
CacheCleaner
in
com.wizzardo.tools.cache

Best Java code snippets using com.wizzardo.tools.cache.CacheCleaner (Showing top 8 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
Charset c =
  • Codota IconString charsetName;Charset.forName(charsetName)
  • Codota IconCharset.defaultCharset()
  • Codota IconContentType contentType;contentType.getCharset()
  • Smart code suggestions by Codota
}
origin: com.wizzardo.tools/tools-cache

private CacheCleaner() {
  setDaemon(true);
  setName(this.getClass().getName());
}
origin: wizzardo/tools

public Cache(String name, long ttlSec, Computable<? super K, ? extends V> computable) {
  this.name = name != null ? name : "Cache-" + NAME_COUNTER.incrementAndGet();
  this.ttl = ttlSec * 1000;
  this.computable = computable;
  statistics = createStatistics();
  timings.put(ttl, new WeakReference<TimingsHolder<K, V>>(timingsHolder = new TimingsHolder<K, V>(ttl)));
  CacheCleaner.addCache(this);
}
origin: com.wizzardo.tools/tools-cache

private void updateTimingCache(final Holder<K, V> key) {
  TimingsHolder<K, V> timingsHolder = key.getTimingsHolder();
  if (timingsHolder == null || timingsHolder.ttl <= 0)
    return;
  long timing = timingsHolder.ttl + System.currentTimeMillis();
  key.setValidUntil(timing);
  CacheCleaner.updateWakeUp(timing);
  timingsHolder.timings.add(new TimingEntry<Holder<K, V>>(key, timing));
}
origin: wizzardo/tools

@Test
public void test_cache_iterable() {
  Cache<String, String> cache;
  cache = new Cache<String, String>(1);
  cache = new Cache<String, String>(1);
  cache = new Cache<String, String>(1);
  int before = CacheCleaner.size();
  Assert.assertTrue(before >= 3);
  System.gc();
  int i = 0;
  for (Cache c : CacheCleaner.iterable()) {
    i++;
  }
  Assert.assertEquals(1, i);
  Assert.assertEquals(1, CacheCleaner.size());
}
origin: wizzardo/tools

@Test
public void destroy_test() throws InterruptedException {
  System.gc();
  Cache<String, String> cache = new Cache<String, String>(1, new Computable<String, String>() {
    @Override
    public String compute(String s) {
      return s.toUpperCase();
    }
  });
  cache.get("foo");
  Assert.assertEquals(1, cache.size());
  Thread.sleep(1020);
  Assert.assertEquals(0, cache.size());
  Assert.assertEquals(1, CacheCleaner.size());
  cache.get("foo");
  Assert.assertEquals(1, cache.size());
  cache.destroy();
  Assert.assertEquals(0, cache.size());
  Assert.assertEquals(true, cache.isDestroyed());
  Assert.assertEquals(1, CacheCleaner.size());
  Thread.sleep(1020);
  Assert.assertEquals(0, CacheCleaner.size());
}
origin: com.wizzardo.tools/tools-cache

public Cache(String name, long ttlSec, Computable<? super K, ? extends V> computable) {
  this.name = name != null ? name : "Cache-" + NAME_COUNTER.incrementAndGet();
  this.ttl = ttlSec * 1000;
  this.computable = computable;
  statistics = createStatistics();
  timings.put(ttl, new WeakReference<TimingsHolder<K, V>>(timingsHolder = new TimingsHolder<K, V>(ttl)));
  CacheCleaner.addCache(this);
}
origin: wizzardo/tools

private void updateTimingCache(final Holder<K, V> key) {
  TimingsHolder<K, V> timingsHolder = key.getTimingsHolder();
  if (timingsHolder == null || timingsHolder.ttl <= 0)
    return;
  long timing = timingsHolder.ttl + System.currentTimeMillis();
  key.setValidUntil(timing);
  CacheCleaner.updateWakeUp(timing);
  timingsHolder.timings.add(new TimingEntry<Holder<K, V>>(key, timing));
}
origin: wizzardo/tools

private CacheCleaner() {
  setDaemon(true);
  setName(this.getClass().getName());
}
com.wizzardo.tools.cacheCacheCleaner

Most used methods

  • addCache
  • setDaemon
  • setName
  • updateWakeUp
  • iterable
  • size

Popular in Java

  • Finding current android device location
  • getContentResolver (Context)
  • setContentView (Activity)
  • findViewById (Activity)
  • InputStream (java.io)
    A readable source of bytes.Most clients will use input streams that read data from the file system (
  • RandomAccessFile (java.io)
    Allows reading from and writing to a file in a random-access manner. This is different from the uni-
  • NumberFormat (java.text)
    The abstract base class for all number formats. This class provides the interface for formatting and
  • Set (java.util)
    A collection that contains no duplicate elements. More formally, sets contain no pair of elements e1
  • Manifest (java.util.jar)
    The Manifest class is used to obtain attribute information for a JarFile and its entries.
  • BasicDataSource (org.apache.commons.dbcp)
    Basic implementation of javax.sql.DataSource that is configured via JavaBeans properties. This is no
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now