| 代码清单1:通过CacheAttributeWeights配置何使用高速缓存
java.util.properties cacheProps = new Properties();
java.util.properties cacheWeights = null;
cacheWeights.setProperty("NLS_LANG", "10");
cacheWeights.setProperty("SecurityGroup", "8");
cacheWeights.setProperty("Application", "4");
...
// set weights on the cache
cacheProps.put(CacheAttributeWeights, cacheWeights);
...
一旦设置了权值,即可发出一个连接请求,如下所示:
java.util.properties connAttr = null;
connAttr.setProperty("NLS_LANG", "ISO-LATIN-1");
connAttr.setProperty("SecurityGroup", "1");
connAttr.setProperty("Application", "HR")
ds.setCacheName("MyCache");
conn = ds.getConnection(connAttr); // request connection from MyCache
...
conn.close(connAttr); // apply attributes to the connection and close it
...
conn = ds.getConnection(connAttr); // next retrieval finds the connection in the cache
...
|