@Documented @Retention(value=RUNTIME) @Target(value={METHOD,CONSTRUCTOR}) public @interface Cacheable
For example, this load() method loads some data from the network
and we want it to cache loaded data for 5 seconds (to avoid delays):
@Cacheable(lifetime = 5, unit = TimeUnit.SECONDS)
String load(String resource) throws IOException {
return "something";
}
You can cache them forever, which means that once calculated and cached value will never expire (may be a nice alternative to static initializers):
@Cacheable(forever = true)
String load(String resource) throws IOException {
return "something";
}public abstract int lifetime
public abstract TimeUnit unit
public abstract boolean forever
Copyright © 2012-2013 jcabi.com. All Rights Reserved.