Tabnine Logo
CacheCleaner
Code IndexAdd Tabnine 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)

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

  • Reactive rest calls using spring rest template
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • runOnUiThread (Activity)
  • scheduleAtFixedRate (Timer)
  • Format (java.text)
    The base class for all formats. This is an abstract base class which specifies the protocol for clas
  • SortedSet (java.util)
    SortedSet is a Set which iterates over its elements in a sorted order. The order is determined eithe
  • Executors (java.util.concurrent)
    Factory and utility methods for Executor, ExecutorService, ScheduledExecutorService, ThreadFactory,
  • HttpServletRequest (javax.servlet.http)
    Extends the javax.servlet.ServletRequest interface to provide request information for HTTP servlets.
  • JLabel (javax.swing)
  • Reflections (org.reflections)
    Reflections one-stop-shop objectReflections scans your classpath, indexes the metadata, allows you t
  • 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