|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.locomotive.util.cache.DBCache
Constructor Summary | |
DBCache()
Default constructor for the database cache. |
|
DBCache(Config config,
DBConnectionPool connectionPool)
Construct a database cache reading default values from a LocoConfig and with a specific connection pool. |
|
DBCache(Config config,
DBConnectionPool connectionPool,
Log server_log)
Construct a database cache reading default values from a Config and with a specific connection pool. |
Method Summary | |
void |
clearCacheForClass(java.lang.String short_class_name,
boolean save_dirty_data)
This method will remove all the items for this class from the cache. |
boolean |
contains(java.lang.String short_class_name,
java.lang.Object key)
Tells whether an Object is in the DBCache. |
boolean |
deleteSerializedObjectFromDB(java.lang.String short_class_name,
java.lang.Object key)
This method deletes an object from the database, but NOT from the cache. |
java.lang.Object |
get(java.lang.String short_class_name,
int int_key)
"convenience" get() method using an int key: |
java.lang.Object |
get(java.lang.String short_class_name,
long long_key)
"convenience" get() method using a long key: |
java.lang.Object |
get(java.lang.String short_class_name,
java.lang.Object key)
This method retrieves an object from the cache. |
int |
getAutoSaveSleepInterval()
|
DBConnectionPool |
getConnectionPool()
Get the connection pool for this cache. |
int |
getDefaultAutoSaveInterval()
|
int |
getDefaultExpirationTime()
|
int |
getExpirationSleepInterval()
|
int |
getMaxEntries()
|
int |
getMaxExpirationTime()
|
protected java.lang.Object |
loadObject(org.locomotive.util.cache.MetaDataEntry class_data,
java.lang.Object key)
|
protected java.lang.Object |
loadSerializedObjectFromDB(org.locomotive.util.cache.MetaDataEntry class_data,
java.lang.Object key)
|
void |
log(int lev,
java.lang.String s)
log to the DBCache server log |
static void |
main(java.lang.String[] argv)
|
void |
put(java.lang.String short_class_name,
java.lang.Object key,
java.lang.Object new_object)
This method puts an object in the cache. |
void |
register(java.lang.String short_class_name,
java.lang.Class class_to_register)
the default register method is: |
void |
register(java.lang.String short_class_name,
java.lang.Class class_to_register,
long expiration_frequency_in_seconds,
long auto_save_frequency_in_seconds,
boolean affects_other_sessions)
The register() method allows you to register your Objects that you want to store in the database, with the DBCache. |
java.lang.Object |
remove(java.lang.String short_class_name,
java.lang.Object key)
This method removes an object from the cache. |
void |
saveRelationalObjectIfDirty(org.locomotive.util.cache.InstanceCacheEntry entry)
This is just a convenience method for ExpirationThread and AutoSaveThread. |
void |
setAutoSaveSleepInterval(int autoSaveSleepInterval)
how long the AutoSaveThread sleeps before waking up to check dirty data in objects, expressed in number of seconds |
void |
setConnectionPool(DBConnectionPool connectionPool)
Set the connection pool this cache. |
void |
setDefaultAutoSaveInterval(int defaultAutoSaveInterval)
how long the AutoSaveThread sleeps before waking up to check dirty data in objects, expressed in number of seconds |
void |
setDefaultExpirationTime(int defaultExpirationTime)
the default frequency for how long an object can remain in the cache (used primarily by the ExpirationThread) expressed in number of seconds. |
void |
setExpirationSleepInterval(int expirationSleepInterval)
how long the ExpirationThread sleeps before waking up to check whether objects have expired, expressed in number of seconds |
void |
setMaxEntries(int maxEntries)
|
void |
setMaxExpirationTime(int maxExpirationTime)
The maximum time that any object can remain in this cache, expressed in number of seconds. |
void |
startService()
Startup the service. |
boolean |
writeSerializedObjectToDB(java.lang.String short_class_name,
java.lang.Object key,
java.lang.Object new_object)
|
boolean |
writeToDB(java.lang.String short_class_name,
java.lang.Object key,
java.lang.Object new_object)
This method will write an Object into the database, without saving it into the cache. |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Constructor Detail |
public DBCache()
public DBCache(Config config, DBConnectionPool connectionPool, Log server_log)
config
- The Config to get default values from.connectionPool
- The connection pool to use for this cache.public DBCache(Config config, DBConnectionPool connectionPool)
config
- The LocoConfig to get default values from.connectionPool
- The connection pool to use for this cache.Method Detail |
public void startService()
public void setMaxEntries(int maxEntries)
public int getMaxEntries()
public void setDefaultExpirationTime(int defaultExpirationTime)
public int getDefaultExpirationTime()
public void setMaxExpirationTime(int maxExpirationTime)
public int getMaxExpirationTime()
public void setExpirationSleepInterval(int expirationSleepInterval)
public int getExpirationSleepInterval()
public void setDefaultAutoSaveInterval(int defaultAutoSaveInterval)
public int getDefaultAutoSaveInterval()
public void setAutoSaveSleepInterval(int autoSaveSleepInterval)
public int getAutoSaveSleepInterval()
public void setConnectionPool(DBConnectionPool connectionPool)
connectionPool
- The connection pool to use for this cache.public DBConnectionPool getConnectionPool()
public void register(java.lang.String short_class_name, java.lang.Class class_to_register, long expiration_frequency_in_seconds, long auto_save_frequency_in_seconds, boolean affects_other_sessions) throws CacheNamingException
short_class_name
- should have only alphanumeric
characters and '_'.auto_save_frequency_in_seconds
- how
often the DBCache should check for dirty data for each
RelationalObject, and write it to the database. Expressed as
the number of seconds between each periodic check.
expiration_in_seconds
- how long, in seconds, an Object
can remain in the cache, without being accessed by
DBCache's get() or put() methods, before it
is removed. We recommend that you make this number reasonably
large, for example, at least 60 seconds, but more typically,
1800 (1/2 hour) or 3600 (1 hour). Otherwise, why bother using
the DBCache at all?
affects_other_sessions
- if this is true, then it means
that we will need to have a consistent view for this
RelationalObject across multiple Locomotive servers. This is
very complicated, and will be implemented later. for now,
this argument is unused; it's just a placeholder.public void register(java.lang.String short_class_name, java.lang.Class class_to_register) throws CacheNamingException
public java.lang.Object get(java.lang.String short_class_name, java.lang.Object key) throws java.sql.SQLException, CacheNamingException
protected java.lang.Object loadObject(org.locomotive.util.cache.MetaDataEntry class_data, java.lang.Object key) throws java.sql.SQLException
protected java.lang.Object loadSerializedObjectFromDB(org.locomotive.util.cache.MetaDataEntry class_data, java.lang.Object key) throws java.sql.SQLException
public java.lang.Object get(java.lang.String short_class_name, int int_key) throws java.sql.SQLException, CacheNamingException
public java.lang.Object get(java.lang.String short_class_name, long long_key) throws java.sql.SQLException, CacheNamingException
public void put(java.lang.String short_class_name, java.lang.Object key, java.lang.Object new_object) throws java.sql.SQLException, CacheNamingException
public boolean writeToDB(java.lang.String short_class_name, java.lang.Object key, java.lang.Object new_object) throws java.sql.SQLException, CacheNamingException
public boolean writeSerializedObjectToDB(java.lang.String short_class_name, java.lang.Object key, java.lang.Object new_object) throws java.sql.SQLException, CacheNamingException
public java.lang.Object remove(java.lang.String short_class_name, java.lang.Object key) throws java.sql.SQLException, CacheNamingException
deleteFromDB()
public boolean deleteSerializedObjectFromDB(java.lang.String short_class_name, java.lang.Object key) throws java.sql.SQLException, CacheNamingException
public boolean contains(java.lang.String short_class_name, java.lang.Object key) throws CacheNamingException
public void clearCacheForClass(java.lang.String short_class_name, boolean save_dirty_data) throws CacheNamingException
save_dirty_data
- if this is true, then each item will be
auto-saved to the database if it has dirty data.public void saveRelationalObjectIfDirty(org.locomotive.util.cache.InstanceCacheEntry entry) throws java.sql.SQLException
public static void main(java.lang.String[] argv)
public void log(int lev, java.lang.String s)
lev
- the log levels
- a string to be logged
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |