Using the QueryManager API
The QueryManager Builder and Interface
BigMemory SQL searches are performed using the QueryManager builder and interface.
public final class QueryManagerBuilder
{
public static QueryManagerBuilder newQueryManagerBuilder()
{
}
public QueryManagerBuilder addCache(Ehcache cache)
{
}
public QueryManagerBuilder addAllCachesCurrentlyIn(CacheManager cacheManager)
{
for (String s : cacheManager.getCacheNames())
{
final Ehcache cache = cacheManager.getEhcache(s);
}
}
public QueryManager build()
{
}
}
public interface QueryManager
{
Query createQuery(String queryString);
}
Specifying Caches to Query
You can explicitly add a cache to be searched by BigMemory SQL, or you can specify the CacheManager that contains the caches. The following example does both:
QueryManager queryManager = QueryManagerBuilder
.newQueryManagerBuilder()
.addCache(cache1)
.addCache(cache2)
.addAllCachesCurrentlyIn(cacheManager1)
.addAllCachesCurrentlyIn(cacheManager2)
.build();
Note:
A build of the QueryManager is a snapshot of the state of the CacheManagers and Caches. If CacheManagers or Caches are added or removed after the build, a new QueryManager should be built before issuing the query.
Specifying the Query
The createQuery() method takes one string argument that represents a BigMemory SQL SELECT clause:
Query query = queryManager.createQuery("queryString");