Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.google.common.cache
Class CacheLoader<K,V>

    java.lang.Object
      com.google.common.cache.CacheLoader<K,V>

    @Beta
    public abstract class CacheLoader<K,V>

extends Object

Computes or retrieves values, based on a key, for use in populating a `Cache`.

Since:
  10.0
Author:
  Charles Fry

Constructor Summary
`CacheLoader()`

Method Summary
`static
`<K,V> CacheLoader<K,V>`
` | `from(Function<K,V> function)` Returns a `CacheLoader` which creates values by applying a `Function` to the key.
`static
`<V> CacheLoader<Object,V>`
` | `from(Supplier<V> supplier)` Returns a `CacheLoader` which obtains values from a `Supplier` (independent of the key).
`abstract V` | `load(K key)` Computes or retrieves the value corresponding to `key`.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### CacheLoader

    public CacheLoader()

Method Detail

### from

    public static <K,V> CacheLoader<K,V> from(Function<K,V> function)

  Returns a `CacheLoader` which creates values by applying a `Function` to the key.

### from

    public static <V> CacheLoader<Object,V> from(Supplier<V> supplier)

  Returns a `CacheLoader` which obtains values from a `Supplier` (independent of the key).

### load

    public abstract V load(K key)
                    throws Exception

  Computes or retrieves the value corresponding to `key`.

  Parameters:
    `key` - the key whose value should be loaded; will never be null
  Returns:
    the value associated with `key`; may not be null
  Throws:
    `Exception`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2010-2011. All Rights Reserved.