org.apache.commons.cache
Class SimpleCache
java.lang.Object
org.apache.commons.cache.BaseCache
org.apache.commons.cache.SimpleCache
- All Implemented Interfaces:
- Serializable, Cache
public class SimpleCache
- extends BaseCache
- implements Cache
tk.
- Version:
- $Id: SimpleCache.java 155435 2005-02-26 13:17:27Z dirkv $
- Author:
- Rodney Waldhoff
- See Also:
- Serialized Form
Constructor Summary |
SimpleCache(Stash stash)
|
SimpleCache(Stash stash,
EvictionPolicy ep)
|
SimpleCache(Stash stash,
EvictionPolicy ep,
StashPolicy sp)
|
SimpleCache(Stash stash,
EvictionPolicy ep,
StashPolicy sp,
GroupMap tm)
|
SimpleCache(Stash stash,
EvictionPolicy ep,
StashPolicy sp,
GroupMap tm,
File persistFile)
|
Methods inherited from class org.apache.commons.cache.BaseCache |
broadcastCleared, broadcastCleared, broadcastNotRetrieved, broadcastNotStored, broadcastRetrieved, broadcastRetrieveRequested, broadcastStored, broadcastStoreRequested, clearGroup, registerRetrievalListener, registerStorageListener, store, unregisterRetrievalListener, unregisterRetrievalListeners, unregisterStorageListener, unregisterStorageListeners |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
_gm
protected GroupMap _gm
_ep
protected EvictionPolicy _ep
_sp
protected StashPolicy _sp
_stash
protected Stash _stash
_wantsSerialized
protected boolean _wantsSerialized
_persistFile
protected File _persistFile
_numRetrieveRequested
protected long _numRetrieveRequested
_numRetrieveFound
protected long _numRetrieveFound
_numStoreRequested
protected long _numStoreRequested
_numStoreStored
protected long _numStoreStored
_numCleared
protected long _numCleared
SimpleCache
public SimpleCache(Stash stash)
SimpleCache
public SimpleCache(Stash stash,
EvictionPolicy ep)
SimpleCache
public SimpleCache(Stash stash,
EvictionPolicy ep,
StashPolicy sp)
SimpleCache
public SimpleCache(Stash stash,
EvictionPolicy ep,
StashPolicy sp,
GroupMap tm)
SimpleCache
public SimpleCache(Stash stash,
EvictionPolicy ep,
StashPolicy sp,
GroupMap tm,
File persistFile)
getStat
public long getStat(CacheStat stat)
throws UnsupportedOperationException
- Specified by:
getStat
in interface Cache
- Overrides:
getStat
in class BaseCache
- Throws:
UnsupportedOperationException
readFromFile
public static SimpleCache readFromFile(String f)
throws IOException,
ClassNotFoundException
- Throws:
IOException
ClassNotFoundException
readFromFile
public static SimpleCache readFromFile(File f)
throws IOException,
ClassNotFoundException
- Throws:
IOException
ClassNotFoundException
writeToFile
protected void writeToFile()
getKeysForGroup
public Serializable[] getKeysForGroup(Serializable group)
- Specified by:
getKeysForGroup
in interface Cache
- Specified by:
getKeysForGroup
in class BaseCache
store
public boolean store(Serializable key,
Serializable val,
Long expiry,
Long cost,
Serializable group)
- Description copied from interface:
Cache
- Store the specified val under the specified
key and the specified group.
- Specified by:
store
in interface Cache
- Specified by:
store
in class BaseCache
- Parameters:
key
- the key used to later obtain the val from me,
which MUST NOT be null.val
- the val to store, which MUST NOT be null.expiry
- the timestamp at which the given val becomes stale, or null.cost
- the implemenation dependent cost of generating the val, or null.group
- a meta-key which can be used to clear the object later
- Returns:
- true if the val was stored, false otherwise.
retrieve
public Serializable retrieve(Serializable key)
- Description copied from interface:
Cache
- Obtain the value previously
stored
under
the given key.
- Specified by:
retrieve
in interface Cache
- Specified by:
retrieve
in class BaseCache
- Parameters:
key
- the key which MUST NOT be null.
- Returns:
- the previously
stored
value, or null.
contains
public boolean contains(Serializable key)
- Description copied from interface:
Cache
- Returns true if I have a value associated with
the given key, false otherwise.
- Specified by:
contains
in interface Cache
- Specified by:
contains
in class BaseCache
- Parameters:
key
- the key which MUST NOT be null.
- Returns:
- true if I have a value associated with
the given key, false otherwise.
clear
public void clear(Serializable key)
- Description copied from interface:
Cache
- Remove any value previously
stored
under
the given key.
- Specified by:
clear
in interface Cache
- Specified by:
clear
in class BaseCache
- Parameters:
key
- the key which MUST NOT be null.
clear
public void clear()
- Description copied from interface:
Cache
- Remove all values previously
stored
.
- Specified by:
clear
in interface Cache
- Specified by:
clear
in class BaseCache
tryToEvict
protected boolean tryToEvict()
main
public static void main(String[] args)
throws Exception
- Throws:
Exception
Copyright © 2001-2010 The Apache Software Foundation. All Rights Reserved.