Java TimeUnit Calculate getExpiringMap(long time, TimeUnit unit)

Here you can find the source of getExpiringMap(long time, TimeUnit unit)

Description

get Expiring Map

License

Open Source License

Declaration

public static <T, V> LoadingCache<T, V> getExpiringMap(long time, TimeUnit unit) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
import java.util.concurrent.TimeUnit;

public class Main {
    public static <T, V> LoadingCache<T, V> getExpiringMap(long time, TimeUnit unit) {
        return (LoadingCache<T, V>) CacheBuilder.newBuilder().concurrencyLevel(1).expireAfterWrite(time, unit)
                .build(new CacheLoader() {
                    public Object load(Object key) {
                        throw new RuntimeException();
                    }//w ww  .j ava 2 s.c om
                });
    }
}

Related

  1. getComingTime(Integer delta, TimeUnit unit)
  2. getDate(final TimeUnit unit, final int offset)
  3. getDateDiff(Date date1, Date date2, TimeUnit timeUnit)
  4. getDateDiff(final Date d1, final Date d2, final TimeUnit timeUnit)
  5. getDifference(Calendar initDate, Calendar endDate, TimeUnit units)
  6. getFragment(final Calendar calendar, final int fragment, final TimeUnit unit)
  7. getFutureDate(long delay, TimeUnit timeUnit)
  8. getInterval(final Date startDate, final Date endDate, final TimeUnit timeUnit)
  9. getIntervalInfo(long intervalDuration, TimeUnit unit)