org.hyperic.hq.product
Class JDBCQueryCache
java.lang.Object
org.hyperic.hq.product.JDBCQueryCache
public class JDBCQueryCache
- extends Object
JDBCQueryCache is a simple caching mechanism to be used with
JDBCMeasurementPlugins.
example:
mysql> select Value, Default from sys_table;
+-----------------------------------+----------+---------+
| Variable_name | Value | Default |
+-----------------------------------+----------+---------+
| DB_Max_Memory | 8192 | 1024 |
| DB_Max_Connections | 400 | 10 |
...
...
String query = "select Value, Default from sys_table";
JDBCQueryCache cache = new JDBCQueryCache(query, "Variable_name", 5000);
Double val = Double.valueOf(cache.get("DB_Max_Memory", "Value").toString());
val = Double.valueOf(cache.get("DB_Max_Connections", "Default").toString());
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
JDBCQueryCache
public JDBCQueryCache(String query,
String queryKey,
long cacheTimeout)
clearCache
public void clearCache()
- Explicitly clears any cached value
setExpireTime
public void setExpireTime(long expireTime)
- Explicitly sets the expire time of the cache to expireTime. Cache will
not repopulate until System.currentTimeMillis() <= expireTime.
getOnlyRow
public Object getOnlyRow(Connection conn,
String column)
throws SQLException,
JDBCQueryCacheException
- Returns:
- Object representation of the *only* row and column value
or null if it does not exist
- Throws:
JDBCQueryCacheException
- if there are 0 or > 1 rows in the cache.
SQLException
get
public Object get(Connection conn,
String key,
String column)
throws JDBCQueryCacheException,
SQLException
- Returns:
- Object representation of the row key/column value or null if it
does not exist
- Throws:
JDBCQueryCacheException
SQLException
Copyright © 2004-2010 Hyperic, Inc. support@hyperic.net, All Rights Reserved.