org.apache.commons.cache
Class FileStash

java.lang.Object
  extended by org.apache.commons.cache.BaseStash
      extended by org.apache.commons.cache.FileStash
All Implemented Interfaces:
Serializable, Stash

public class FileStash
extends BaseStash
implements Stash

tk.

Version:
$Id: FileStash.java 155435 2005-02-26 13:17:27Z dirkv $
Author:
Rodney Waldhoff
See Also:
Serialized Form

Field Summary
protected  Cache _cache
           
protected  boolean _cleanupfiles
           
protected  long _curBytes
           
protected  HashMap _hash
           
protected  long _maxBytes
           
protected  long _maxObjs
           
protected  int _tempfileCounter
           
protected  File[] _tempFileDirs
           
protected  String _tempFilePrefix
           
protected  String _tempFileSuffix
           
static String DEFAULT_FILE_PREFIX
           
static String DEFAULT_FILE_SUFFIX
           
static long DEFAULT_MAX_BYTES
           
static long DEFAULT_MAX_OBJS
           
static File[] DEFAULT_TEMP_DIRS
           
 
Fields inherited from interface org.apache.commons.cache.Stash
NO, NO_FULL, NO_NOT_STORABLE, YES
 
Constructor Summary
FileStash()
           
FileStash(long maxbytes)
           
FileStash(long maxbytes, long maxobjs)
           
FileStash(long maxbytes, long maxobjs, File[] tempdirs, boolean cleanup)
           
FileStash(long maxbytes, long maxobjs, File rootdir, int numdirs)
           
FileStash(long maxbytes, long maxobjs, File rootdir, int numdirs, boolean cleanup)
           
FileStash(long maxbytes, long maxobjs, String rootdir, int numdirs)
           
FileStash(long maxbytes, long maxobjs, String rootdir, int numdirs, boolean cleanup)
           
 
Method Summary
 int canStore(Serializable key, Serializable val, Long expiresAt, Long cost, Serializable group, byte[] serialized)
           
 float capacity()
           
 void clear()
           
 void clear(Serializable key)
           
 boolean contains(Serializable key)
           
protected  byte[] getSerializedForm(Serializable val)
           
protected  File getTempfile()
           
protected  Serializable readFromFile(File file)
           
 Serializable retrieve(Serializable key)
           
 void setCache(Cache c)
           
 boolean store(Serializable key, Serializable val, Long expiresAt, Long cost, Serializable group, byte[] serialized)
           
 void unsetCache()
           
 boolean wantsSerializedForm()
          Returns false.
 
Methods inherited from class org.apache.commons.cache.BaseStash
canStore, store
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.commons.cache.Stash
canStore, store
 

Field Detail

DEFAULT_MAX_OBJS

public static final transient long DEFAULT_MAX_OBJS

DEFAULT_MAX_BYTES

public static final transient long DEFAULT_MAX_BYTES

DEFAULT_TEMP_DIRS

public static final transient File[] DEFAULT_TEMP_DIRS

DEFAULT_FILE_PREFIX

public static final transient String DEFAULT_FILE_PREFIX

DEFAULT_FILE_SUFFIX

public static final transient String DEFAULT_FILE_SUFFIX

_hash

protected HashMap _hash

_maxObjs

protected long _maxObjs

_maxBytes

protected long _maxBytes

_cache

protected Cache _cache

_curBytes

protected long _curBytes

_tempFileDirs

protected File[] _tempFileDirs

_tempFilePrefix

protected String _tempFilePrefix

_tempFileSuffix

protected String _tempFileSuffix

_cleanupfiles

protected boolean _cleanupfiles

_tempfileCounter

protected int _tempfileCounter
Constructor Detail

FileStash

public FileStash()

FileStash

public FileStash(long maxbytes)

FileStash

public FileStash(long maxbytes,
                 long maxobjs)

FileStash

public FileStash(long maxbytes,
                 long maxobjs,
                 File[] tempdirs,
                 boolean cleanup)

FileStash

public FileStash(long maxbytes,
                 long maxobjs,
                 String rootdir,
                 int numdirs)

FileStash

public FileStash(long maxbytes,
                 long maxobjs,
                 String rootdir,
                 int numdirs,
                 boolean cleanup)

FileStash

public FileStash(long maxbytes,
                 long maxobjs,
                 File rootdir,
                 int numdirs)

FileStash

public FileStash(long maxbytes,
                 long maxobjs,
                 File rootdir,
                 int numdirs,
                 boolean cleanup)
Method Detail

getSerializedForm

protected byte[] getSerializedForm(Serializable val)

readFromFile

protected Serializable readFromFile(File file)

canStore

public int canStore(Serializable key,
                    Serializable val,
                    Long expiresAt,
                    Long cost,
                    Serializable group,
                    byte[] serialized)
Specified by:
canStore in interface Stash
Specified by:
canStore in class BaseStash

getTempfile

protected File getTempfile()

store

public boolean store(Serializable key,
                     Serializable val,
                     Long expiresAt,
                     Long cost,
                     Serializable group,
                     byte[] serialized)
Specified by:
store in interface Stash
Specified by:
store in class BaseStash

retrieve

public Serializable retrieve(Serializable key)
Specified by:
retrieve in interface Stash
Specified by:
retrieve in class BaseStash

contains

public boolean contains(Serializable key)
Specified by:
contains in interface Stash
Specified by:
contains in class BaseStash

capacity

public float capacity()
Specified by:
capacity in interface Stash
Specified by:
capacity in class BaseStash

clear

public void clear(Serializable key)
Specified by:
clear in interface Stash
Specified by:
clear in class BaseStash

clear

public void clear()
Specified by:
clear in interface Stash

setCache

public void setCache(Cache c)
Specified by:
setCache in interface Stash
Specified by:
setCache in class BaseStash

unsetCache

public void unsetCache()
Specified by:
unsetCache in interface Stash
Specified by:
unsetCache in class BaseStash

wantsSerializedForm

public boolean wantsSerializedForm()
Description copied from class: BaseStash
Returns false.

Specified by:
wantsSerializedForm in interface Stash
Overrides:
wantsSerializedForm in class BaseStash
Returns:
false.


Copyright © 2001-2010 The Apache Software Foundation. All Rights Reserved.