public void clean(Config config, DatasourceConnection dc, int type,StorageScopeEngine engine,DatasourceStorageScopeCleaner cleaner,StorageScopeListener listener, Log log) throws PageException {
String strType = VariableInterpreter.scopeInt2String(type);
// select
SQL sqlSelect=new SQLImpl("select cfid,name from "+PREFIX+"_"+strType+"_data where expires<=?"
,new SQLItem[]{
new SQLItemImpl(System.currentTimeMillis(),Types.VARCHAR)
});
QueryImpl query;
try{
query = new QueryImpl(ThreadLocalPageContext.get(),dc,sqlSelect,-1,-1,-1,"query");
}
catch(Throwable t){
// possible that the table not exist, if not there is nothing to clean
return;
}
int recordcount=query.getRecordcount();
String cfid,name;
for(int row=1;row<=recordcount;row++){
cfid=Caster.toString(query.getAt(KeyConstants._cfid, row, null),null);
name=Caster.toString(query.getAt(KeyConstants._name, row, null),null);
if(listener!=null)listener.doEnd(engine, cleaner,name, cfid);
ScopeContext.info(log,"remove "+strType+"/"+name+"/"+cfid+" from datasource "+dc.getDatasource().getName());
engine.remove(type,name,cfid);
SQLImpl sql = new SQLImpl("delete from "+StorageScopeDatasource.PREFIX+"_"+strType+"_data where cfid=? and name=?",new SQLItem[]{
new SQLItemImpl(cfid,Types.VARCHAR),
new SQLItemImpl(name,Types.VARCHAR)
});
new QueryImpl(ThreadLocalPageContext.get(),dc,sql,-1,-1,-1,"query");