Same concept Optional class is going to be added to the core java.util library in jdk8
More detalails here: https://code.google.com/p/guava-libraries/wiki/UsingAndAvoidingNullExplained
Same concept Optional class is going to be added to the core java.util library in jdk8
More detalails here: https://code.google.com/p/guava-libraries/wiki/UsingAndAvoidingNullExplained
A rate limiter. Conceptually, a rate limiter distributes permits at a configurable rate. Each acquire() blocks if necessary until a permit is available, and then takes it. Once acquired, permits need not be released.
Rate limiters are often used to restrict the rate at which some physical or logical resource is accessed. This is in contrast to Semaphore which restricts the number of concurrent accesses instead of the rate.
You can read more in guava javadoc:
http://docs.guava-libraries.googlecode.com/git/javadoc/com/google/common/util/concurrent/RateLimiter.html
private LoadingCache<String, MyClass> cache;
CacheLoader<String, MyClass> loader = new CacheLoader<String, MyClass> () {
public MyClass load(String key) throws Exception {
return ourService.get(key);
}
};
cache = CacheBuilder.newBuilder().
expireAfterWrite(1, TimeUnit.MINUTES).
build(loader);
More about this subject here: http://code.google.com/p/guava-libraries/wiki/CachesExplained