use of com.github.drinkjava2.jdbpro.handler.CacheSqlHandler in project jSqlBox by drinkjava2.
the class ImprovedQueryRunner method readCache.
/**
* Explain SQL to cached result object, if have
*/
private Object[] readCache(ResultSetHandler<?> rsh, String sql, Object... params) {
Object[] result = new Object[2];
String key = null;
if (handlers != null)
for (ResultSetHandler handler : handlers) if (handler instanceof CacheSqlHandler) {
if (key == null)
key = createKey(sql, params);
result[0] = key;
Object value = ((CacheSqlHandler) handler).readFromCache(key);
if (value != null) {
result[1] = value;
return result;
}
}
for (ResultSetHandler handler : getThreadedHandlers()) if (handler instanceof CacheSqlHandler) {
if (key == null)
key = createKey(sql, params);
result[0] = key;
Object value = ((CacheSqlHandler) handler).readFromCache(key);
if (value != null) {
result[1] = value;
return result;
}
}
if (rsh != null && rsh instanceof CacheSqlHandler) {
if (key == null)
key = createKey(sql, params);
result[0] = key;
Object value = ((CacheSqlHandler) rsh).readFromCache(key);
if (value != null)
result[1] = value;
}
return result;
}
Aggregations