## net.dontdrinkandroot.lastfm.api.ws
Class DefaultLastfmWebServices

    java.lang.Object
      net.dontdrinkandroot.lastfm.api.ws.AbstractLastfmWebServices
          net.dontdrinkandroot.lastfm.api.ws.DefaultLastfmWebServices

All Implemented Interfaces:
  LastfmWebServices

    public class DefaultLastfmWebServices

extends AbstractLastfmWebServices

Field Summary

Fields inherited from class net.dontdrinkandroot.lastfm.api.ws.AbstractLastfmWebServices
`logger`

Constructor Summary
`DefaultLastfmWebServices(java.lang.String key, java.lang.String secret, net.dontdrinkandroot.cache.CustomTtlCache<java.io.Serializable,java.io.Serializable> cache)` Set up the WebServices with the required components.
`DefaultLastfmWebServices(java.lang.String key, java.lang.String secret, net.dontdrinkandroot.cache.CustomTtlCache<java.io.Serializable,java.io.Serializable> cache, Fetcher fetcher)`

Method Summary
`net.dontdrinkandroot.cache.Cache<java.io.Serializable,java.io.Serializable>` `getCache()` Retrieve the `Cache` instance that is used by the webservices.
`protected java.io.Serializable` `getFromCache(java.lang.String id)` Try to fetch the result from cache.
`protected java.io.Serializable` `putToCache(java.lang.String id, java.io.Serializable result, long timeToLive)` Store result in cache.

Methods inherited from class net.dontdrinkandroot.lastfm.api.ws.AbstractLastfmWebServices
`execute, fetch, fetch, getApiKey, getApiSecret, getFetcher, setFetcher, setTimeToLive`

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

Constructor Detail

### DefaultLastfmWebServices

    public DefaultLastfmWebServices(java.lang.String key,
                                    java.lang.String secret,
                                    net.dontdrinkandroot.cache.CustomTtlCache<java.io.Serializable,java.io.Serializable> cache)
                             throws javax.xml.parsers.ParserConfigurationException

  Set up the WebServices with the required components.

  Parameters:
    `key` - The last.fm API key, see http://www.last.fm/api/account
    `secret` - The last.fm API secret, see http://www.last.fm/api/account
    `cache` - The cache implementation
  Throws:
    `javax.xml.parsers.ParserConfigurationException`

### DefaultLastfmWebServices

    public DefaultLastfmWebServices(java.lang.String key,
                                    java.lang.String secret,
                                    net.dontdrinkandroot.cache.CustomTtlCache<java.io.Serializable,java.io.Serializable> cache,
                                    Fetcher fetcher)

Method Detail

### getCache

    public final net.dontdrinkandroot.cache.Cache<java.io.Serializable,java.io.Serializable> getCache()

  Retrieve the `Cache` instance that is used by the webservices.

  Returns:
    The `Cache` instance.

### getFromCache

    protected java.io.Serializable getFromCache(java.lang.String id)

  Try to fetch the result from cache.

  Specified by:
    `getFromCache` in class `AbstractLastfmWebServices`
  Type Parameters:
    `T` - Return type of the query.
  Parameters:
    `id` - Id to lookup.
  Returns:
    The entry if found or null.

### putToCache

    protected java.io.Serializable putToCache(java.lang.String id,
                                              java.io.Serializable result,
                                              long timeToLive)

  Store result in cache.

  Specified by:
    `putToCache` in class `AbstractLastfmWebServices`
  Type Parameters:
    `T` - Return type of the query.
  Parameters:
    `id` - The id to store the entry for.
    `result` - The query result.
    `timeToLive` - The time to live for the cache entry.
  Returns:
    The cached result or the original result on caching errors.

Copyright © 2012. All Rights Reserved.