private static Pattern CACHE_HINT = Pattern.compile("/\\*\\+?\\s*cache(\\(\\s*(pref_mem)?\\s*(ttl:\\d{1,19})?\\s*(updatable)?\\s*(scope:(session|vdb|user))?[^\\)]*\\))?[^\\*]*\\*\\/.*", Pattern.CASE_INSENSITIVE | Pattern.DOTALL); //$NON-NLS-1$
static CacheHint getQueryCacheOption(String query) {
Matcher match = CACHE_HINT.matcher(query);
if (match.matches()) {
CacheHint hint = new CacheHint();
if (match.group(2) !=null) {
hint.setPrefersMemory(true);
}
String ttl = match.group(3);
if (ttl != null) {
hint.setTtl(Long.valueOf(ttl.substring(4)));
}
if (match.group(4) != null) {
hint.setUpdatable(true);
}
String scope = match.group(5);
if (scope != null) {
scope = scope.substring(6);
hint.setScope(scope);
}
return hint;
}
return null;
}