org.deltava.util.cache
Class FileCache

java.lang.Object
  extended by org.deltava.util.cache.Cache<CacheableFile>
      extended by org.deltava.util.cache.FileCache
Direct Known Subclasses:
FileSystemCache

public class FileCache
extends Cache<CacheableFile>

A cache for File handles.

Since:
2.2
Version:
3.1
Author:
Luke

Nested Class Summary
protected static class FileCache.FileCacheEntry
           
 
Field Summary
 
Fields inherited from class org.deltava.util.cache.Cache
_cache
 
Constructor Summary
FileCache(int maxSize)
          Initializes the cache.
 
Method Summary
protected  void addEntry(CacheableFile obj)
          Adds an entry to the cache.
protected  void addNullEntry(Object key)
          Not implemented.
 void clear()
          Clears the cache and deletes any cached files.
 CacheableFile get(Object key)
          Returns an entry from the cache.
 void remove(Object key)
          Invalidates a cache entry and deletes the file from the filesystem.
 void setMaxAge(int age)
          Sets the maximum age of a file before it should be expired (and deleted) when queried.
 
Methods inherited from class org.deltava.util.cache.Cache
add, addAll, addNull, checkOverflow, contains, getHits, getMaxSize, getRequests, hit, request, setMaxSize, size
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileCache

public FileCache(int maxSize)
Initializes the cache.

Parameters:
maxSize - the maximum number of entries in the cache
Method Detail

addEntry

protected void addEntry(CacheableFile obj)
Adds an entry to the cache.

Specified by:
addEntry in class Cache<CacheableFile>
Parameters:
obj - the file to add to the cache

addNullEntry

protected void addNullEntry(Object key)
Not implemented.

Specified by:
addNullEntry in class Cache<CacheableFile>
Parameters:
key - the entry key

remove

public final void remove(Object key)
Invalidates a cache entry and deletes the file from the filesystem.

Overrides:
remove in class Cache<CacheableFile>
Parameters:
key - the entry key

clear

public final void clear()
Clears the cache and deletes any cached files.

Overrides:
clear in class Cache<CacheableFile>

setMaxAge

public void setMaxAge(int age)
Sets the maximum age of a file before it should be expired (and deleted) when queried.

Parameters:
age - the age in minutes or 0 for no expiration

get

public CacheableFile get(Object key)
Returns an entry from the cache.

Specified by:
get in class Cache<CacheableFile>
Parameters:
key - the cache key
Returns:
the file, or null if not present


Copyright © 2004-2009 Global Virtual Airlines Group. All Rights Reserved.