|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectkrati.sos.SerializableObjectCache<T>
T
- Serializable object.public class SerializableObjectCache<T>
A simple data cache for serializable objects. This class is not thread-safe by design. It is expected that the conditions below hold within one JVM.
1. There is one and only one instance of SerializableObjectCache for a given data cache. 2. There is one and only one thread is calling set and delete methods at any given time.It is expected that this class is used in the case of multiple readers and single writer.
Field Summary | |
---|---|
protected DataCache |
_cache
|
protected ObjectSerializer<T> |
_serializer
|
Constructor Summary | |
---|---|
SerializableObjectCache(DataCache cache,
ObjectSerializer<T> serializer)
Constructs an array-like object cache for serializable objects. |
Method Summary | |
---|---|
void |
clear()
Clears this object cache by removing all the persisted data permanently. |
boolean |
delete(int objectId,
long scn)
Deletes an object based on a user-specified object Id. |
T |
get(int objectId)
Gets an object based on a user-specified object Id. |
byte[] |
getBytes(int objectId)
Gets an object in raw bytes based on a user-specified object Id. |
protected DataCache |
getContentCache()
|
long |
getHWMark()
Gets the high water mark. |
long |
getLWMark()
Gets the low water mark. |
int |
getObjectIdCount()
|
int |
getObjectIdStart()
|
ObjectSerializer<T> |
getSerializer()
|
void |
persist()
Persists this object cache. |
void |
saveHWMark(long endOfPeriod)
Saves the high water mark. |
boolean |
set(int objectId,
T object,
long scn)
Sets an object at a user-specified object Id. |
void |
sync()
Sync this object cache. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected final DataCache _cache
protected final ObjectSerializer<T> _serializer
Constructor Detail |
---|
public SerializableObjectCache(DataCache cache, ObjectSerializer<T> serializer)
cache
- the underlying data cache to store serializable objects.serializer
- the object serializer to serialize/de-serialize objects.Method Detail |
---|
protected DataCache getContentCache()
public ObjectSerializer<T> getSerializer()
public int getObjectIdCount()
getObjectIdCount
in interface ObjectCache<T>
public int getObjectIdStart()
getObjectIdStart
in interface ObjectCache<T>
public T get(int objectId)
get
in interface ObjectCache<T>
objectId
- the Id of an object to be retrieved from the cache.
public boolean set(int objectId, T object, long scn) throws Exception
set
in interface ObjectCache<T>
objectId
- the object Id.object
- the object to put into the cache.scn
- the global scn (equivalent to a time stamp).
Exception
public boolean delete(int objectId, long scn) throws Exception
delete
in interface ObjectCache<T>
objectId
- the object Id.scn
- the global scn (equivalent to a time stamp).
Exception
public void sync() throws IOException
sync
in interface Persistable
IOException
public void persist() throws IOException
persist
in interface Persistable
persist
in interface ObjectCache<T>
IOException
public void clear() throws IOException
clear
in interface ObjectCache<T>
IOException
public long getHWMark()
Persistable
getHWMark
in interface Persistable
public long getLWMark()
Persistable
getLWMark
in interface Persistable
public void saveHWMark(long endOfPeriod) throws Exception
saveHWMark
in interface Persistable
Exception
public byte[] getBytes(int objectId)
getBytes
in interface ObjectCache<T>
objectId
- the Id of an object to be retrieved from the cache.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |