Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Hyperic HQ Plugin API v. 5.8.1
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## 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());`

Constructor Summary
`JDBCQueryCache(String query, String queryKey, long cacheTimeout)`

Method Summary
`void` | `clearCache()` Explicitly clears any cached value
`Object` | `get(Connection conn, String key, String column)`
`Object` | `getOnlyRow(Connection conn, String column)`
`void` | `setExpireTime(long expireTime)` Explicitly sets the expire time of the cache to expireTime.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### JDBCQueryCache

    public JDBCQueryCache(String query,
                          String queryKey,
                          long cacheTimeout)

Method Detail

### 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`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Hyperic HQ Plugin API v. 5.8.1
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2004-2010 Hyperic, Inc. support@hyperic.net, All Rights Reserved.