Project

General

Profile

« Previous | Next » 

Revision 6774

Added by Jing Tao over 12 years ago

Change the key of query result cache. The key now has the real search value.

View differences:

DBQuery.java
694 694
        
695 695
      }
696 696
      logMetacat.debug("DBQuery.findResultDoclist - final selection query: " + query);
697
      String selectionAndExtendedQuery = null;
697
      
698
    
699
      pstmt = dbconn.prepareStatement(query);     
700
      // set all the values we have collected 
701
      pstmt = setPreparedStatementValues(parameterValues, pstmt);
702
      
703
      String queryCacheKey = null;
698 704
      // we only get cache for public
699 705
      if (user != null && user.equalsIgnoreCase("public") 
700
     		 && pagesize == 0 && PropertyService.getProperty("database.queryCacheOn").equals("true"))
706
         && pagesize == 0 && PropertyService.getProperty("database.queryCacheOn").equals("true"))
701 707
      {
702
    	  selectionAndExtendedQuery = query +qspec.getReturnDocList()+qspec.getReturnFieldList();
703
   	      String cachedResult = getResultXMLFromCache(selectionAndExtendedQuery);
704
   	      logMetacat.debug("DBQuery.findResultDoclist - The key of query cache is " + selectionAndExtendedQuery);
705
   	      //System.out.println("==========the string from cache is "+cachedResult);
706
   	      if (cachedResult != null)
707
   	      {
708
   	    	logMetacat.info("DBQuery.findResultDoclist - result from cache !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
709
   	    	 if (out != null)
710
   	         {
711
   	             out.write(cachedResult);
712
   	         }
713
   	    	 resultsetBuffer.append(cachedResult);
714
   	    	 return resultsetBuffer;
715
   	      }
708
          queryCacheKey = pstmt.toString() +qspec.getReturnDocList()+qspec.getReturnFieldList();
709
          String cachedResult = getResultXMLFromCache(queryCacheKey);
710
          logMetacat.debug("=======DBQuery.findResultDoclist - The key of query cache is " + queryCacheKey);
711
          //System.out.println("==========the string from cache is "+cachedResult);
712
          if (cachedResult != null)
713
          {
714
          logMetacat.info("DBQuery.findResultDoclist - result from cache !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
715
           if (out != null)
716
             {
717
                 out.write(cachedResult);
718
             }
719
           resultsetBuffer.append(cachedResult);
720
           pstmt.close();
721
           return resultsetBuffer;
722
          }
716 723
      }
717 724
      
718 725
      startTime = System.currentTimeMillis() / 1000;
719
      pstmt = dbconn.prepareStatement(query);
720
      
721
      // set all the values we have collected 
722
      pstmt = setPreparedStatementValues(parameterValues, pstmt);
723
      
724 726
      logMetacat.debug("Prepared statement after setting parameter values: " + pstmt.toString());
725 727
      rs = pstmt.executeQuery();
726 728

  
......
863 865
    		 && pagesize == NONPAGESIZE && PropertyService.getProperty("database.queryCacheOn").equals("true"))
864 866
     {
865 867
       //System.out.println("the string stored into cache is "+ resultsetBuffer.toString());
866
  	   storeQueryResultIntoCache(selectionAndExtendedQuery, resultsetBuffer.toString());
868
  	   storeQueryResultIntoCache(queryCacheKey, resultsetBuffer.toString());
867 869
     }
868 870
          
869 871
     return resultsetBuffer;

Also available in: Unified diff