Package de.umass.lastfm.cache
Class DefaultExpirationPolicy
java.lang.Object
de.umass.lastfm.cache.DefaultExpirationPolicy
- All Implemented Interfaces:
ExpirationPolicy
This Policy maintains a list of methods which should be cached one week. Everything else won't be cached if
using this policy.
- Author:
- Janni Kovacs
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected long
Contains the expiration time for weekly chart data for the current week, which is one week by default; last.fm TOS says: "You agree to cache similar artist and any chart data (top tracks, top artists, top albums) for a minimum of one week." but they might be outdated the next day.protected static final long
One day in millisecondsprotected static final long
One week in millisecondsContains method names for all requests that should be cached 1 week -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionlong
getExpirationTime
(String method, Map<String, String> params) Returns the time in milliseconds a request of the given method should be cached.void
setCacheRecentWeeklyCharts
(long cacheRecentWeeklyCharts)
-
Field Details
-
ONE_DAY
protected static final long ONE_DAYOne day in milliseconds- See Also:
-
ONE_WEEK
protected static final long ONE_WEEKOne week in milliseconds- See Also:
-
ONE_WEEK_METHODS
Contains method names for all requests that should be cached 1 week -
cacheRecentWeeklyCharts
protected long cacheRecentWeeklyChartsContains the expiration time for weekly chart data for the current week, which is one week by default; last.fm TOS says: "You agree to cache similar artist and any chart data (top tracks, top artists, top albums) for a minimum of one week." but they might be outdated the next day. For now we will cache them one week. If you always need the latest charts but don't want to disable caching use thesetCacheRecentWeeklyCharts(long)
method to set this value. This variable also applies to the getWeeklyChartList method
-
-
Constructor Details
-
DefaultExpirationPolicy
public DefaultExpirationPolicy()
-
-
Method Details
-
getExpirationTime
Description copied from interface:ExpirationPolicy
Returns the time in milliseconds a request of the given method should be cached. Returns -1 if this method should not be cached.- Specified by:
getExpirationTime
in interfaceExpirationPolicy
- Parameters:
method
- The method calledparams
- The parameters sent- Returns:
- the time the request should be cached in milliseconds
-
setCacheRecentWeeklyCharts
public void setCacheRecentWeeklyCharts(long cacheRecentWeeklyCharts)
-