|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--net.sf.spif.StoreChain | +--net.sf.spif.StoreCache
A caching store chain element. This will cache some number of last recently accessed elements passing through the cache.
This class is backed by a Cache
.
Note that straightforward setup of a cache may in theory break rollback semantics, but only if the rollback exception is thrown after leaving this bean, i.e. not when writing to persistent storage, but when committing (usually when leaving the store session bean). If the cache is reading through for write, if will on such cases just expose read-only uncommitted data, which is seldom a problem, but if the cache is set up to not read trhough on writes, uncommitted values may be the basis for subsequent writes. This may or may not be a problem, depending on the application (and on whether committ exceptions is actually technically plausible). If you use a system where it is, and you need this kind of security, you should wrap the session bean starting the transaction in another session bean which cleans up the cache state.
Field Summary |
Fields inherited from class net.sf.spif.StoreChain |
chained |
Constructor Summary | |
StoreCache(boolean readThroughForWrite)
Creates a store cache with the default size (1000) |
|
StoreCache(int size)
Creates a store cache with a size which will read through for write |
|
StoreCache(int size,
boolean readThroughForWrite)
Creates a store cache with a size |
Method Summary | |
void |
clear()
Forgets everything |
java.lang.Object |
get(Id id,
boolean writeable)
Returns an object. |
java.lang.Object |
getCached(Id id)
Returns the value bound to this id in the cache, i.e no forwarding. |
void |
printContents()
Prints the contents of the cache for debugging |
Id |
put(Id id,
java.lang.Object object)
Puts a changed or new object into the store. |
boolean |
remove(Id id)
Removes and propagates |
int |
size()
|
Methods inherited from class net.sf.spif.StoreChain |
equals, getChained, getChained, getChained, hashCode, setChained |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public StoreCache(boolean readThroughForWrite)
readThroughForWrite
- if true this cache will propagate
get(id,true) requests through the cache. If the content of
the underlying may change without coming through this cache,
this should be true. Otherwise it is safe to use false.public StoreCache(int size, boolean readThroughForWrite)
public StoreCache(int size)
Method Detail |
public java.lang.Object get(Id id, boolean writeable)
get
in class StoreChain
id
- the id of the object to return
public java.lang.Object getCached(Id id)
public Id put(Id id, java.lang.Object object)
put
in class StoreChain
id
- the id of the object to put. May be nullobject
- the object to put. May be null
public boolean remove(Id id)
remove
in class StoreChain
id
- the id of the object to remove
public int size()
public void clear()
clear
in class StoreChain
public void printContents()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |