LoadingCache.getAll(Iterable<? extends K> keys, CacheLoader<K, V> loader) ?

843 views
Skip to first unread message

Julio

unread,
Apr 15, 2013, 9:01:28 PM4/15/13
to guava-...@googlegroups.com
What is the rationale for not having a 'getAll' method in LoadingCache
that allows for passing a custom loader?  For example, something like:

'LoadingCache.getAll(Iterable<? extends K> keys, CacheLoader<K, V> loader)'

This would be similar to Cache.get(K key, Callable<? extends V> valueLoader),
but for the purpose of loading multiple values.  For example, this would be
useful for cases when the following conditions apply:

* Context from the caller can (or needs) to be used to load the keys; and

* The cost of loading a key can be amortized over multiple keys (for example, reading from a remote host or a database).

What do you folks think?

Cheers,

-Julio

Charles Fry

unread,
Apr 16, 2013, 5:36:04 AM4/16/13
to Julio, guava-discuss
In my mind the main motivation is that such an implementation is trivial to implement (Cache.getAllPresent + CacheLoader.loadAll + Cache.putAll), while also being very rarely required. So it doesn't pay for the API space it takes up, nor does it introduce any added efficiencies.

Charles


--
--
guava-...@googlegroups.com
Project site: http://guava-libraries.googlecode.com
This group: http://groups.google.com/group/guava-discuss
 
This list is for general discussion.
To report an issue: http://code.google.com/p/guava-libraries/issues/entry
To get help: http://stackoverflow.com/questions/ask (use the tag "guava")
 
---
You received this message because you are subscribed to the Google Groups "guava-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to guava-discus...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Reply all
Reply to author
Forward
0 new messages