|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.sourceforge.rssowl.util.archive.FeedCacheManager
Cache manager for RSSOwl. Any loaded newsfeed is stored in the cache folder and indexed in the newsFeedCache Hashtable. That index is serialized into a file and loaded on startup of RSSOwl. Two Hashtables manage the caching. The live cache contains Channel objects withe the URL as key, whereas the local cache contains File objects which point to the cached file where the newsfeed is stored.
Field Summary | |
private static String |
CACHE_INDEX
File to serialize the cache index into |
private static long |
FILE_TIME_TO_LIVE
Max time to live for unmodified cache files (2 days) |
private Hashtable |
newsFeedLiveCache
Live cache will store RSSChannels |
private Hashtable |
newsFeedLocalCache
Local cache will store File reference to cached files |
Constructor Summary | |
FeedCacheManager()
Instantiate a new FeedCacheManager |
Method Summary | |
void |
cacheNewsfeed(String url,
Channel rssChannel)
Cache a newsfeed |
private void |
cleanUpCache()
Remove those files from the archive which were not modified over a long period |
private void |
deleteCache()
Delete the cache as it is no longer used in RSSOwl |
private void |
deserializeCache()
Load the local cache index from local file |
Channel |
getCachedNewsfeed(String url)
Get a cached newsfeed from the feed cache |
boolean |
isNewsfeedCached(String url)
Check if a newsfeed is cached by a unique identifier in either the live cache (memory) or local (file) |
boolean |
isNewsfeedCached(String url,
boolean allowLocalCache)
Check if a newsfeed is cached by a unique identifier in either the live cache (memory) and local (file) is allowLocalCache is set to TRUE |
private File |
saveDocument(org.jdom.Document document)
Save the newsfeed's XML document into a unique file in the cache dir and return the reference to the new file |
private void |
serializeCache()
Save the chache index into local file |
void |
shutdown()
Serialize the index on application exit and cleanup old chache items |
void |
unCacheNewsfeed(String url,
boolean deleteLocalCache)
Remove a newsfeed from the cache and delete its cache file |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
private static final String CACHE_INDEX
private static final long FILE_TIME_TO_LIVE
private Hashtable newsFeedLiveCache
private Hashtable newsFeedLocalCache
Constructor Detail |
public FeedCacheManager()
Method Detail |
public void cacheNewsfeed(String url, Channel rssChannel)
url
- Unique identifierrssChannel
- The newsfeed to cachepublic Channel getCachedNewsfeed(String url)
url
- Unique identifier
public boolean isNewsfeedCached(String url)
url
- Unique identifier
public boolean isNewsfeedCached(String url, boolean allowLocalCache)
url
- Unique identifierallowLocalCache
- If TRUE also look in local file cache
public void shutdown()
public void unCacheNewsfeed(String url, boolean deleteLocalCache)
url
- Unique identifierdeleteLocalCache
- If TRUE, also uncache local fileprivate void cleanUpCache()
private void deleteCache()
private void deserializeCache()
private File saveDocument(org.jdom.Document document) throws IOException
document
- The newsfeed's document to save
IOException
- If an error occursprivate void serializeCache()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |