I am trying to implement the LoadingCache and in it I must override the load() method.
However, the documentation is a bit lacking and I can't seem to find any decent examples surrounding this. My questions for this are:
LoadingCache
doesn't have a load()
method, CacheLoader
does. And if you read the CachesExplained page of the wiki in addition to the javadoc, I think there's plenty of documentation:
LoadingCache
will automatically compute values it doesn't already have (because they never were requested, or were evicted) when they are requested by key.CacheLoader
which given a key, returns the value: that's the job of the V load(K key)
method, the only abstract method of CacheLoader
, the one you need to implement.