Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    invalidateCache for FETCH

    In my application they may receive big lists of records (>1000), and I fear, that ListGrid may slow down because of caching all those records (if the user passes all of them). So, I tried to use setInvalidateCache(true) in transformResponse; but my experiments showed, that it works only on ADD/DELETE/UPDATE, but is ignored on FETCH operations.

    How can I avoid inflating of the cache? I don't wish create special button for explicit invalidating of the cache - it is uncomfortable for users.

    #2
    We'd recommend not trying not to do this at all. With a large dataset, cache is naturally dropped as the user sorts or changes filter criteria. If the user spends a very long time scrolling around they can temporarily, slightly reduce responsiveness on some browsers, and this goes away as soon as they change sort or similar. It's a non-issue.

    Comment


      #3
      So what to do if user works with cache long time and on the server side concurrent user updates one of the record? In such situation we should do invlidate cache, otherwise first user won't see changes in cached record.

      Comment


        #4
        If it's critical that the other user knows immediately, use a streaming solution like SmartClient's Messaging module. If it's not, either allow the user to naturally invalidate the cache via filter or sort, or track a table-wide timestamp for most recent modification and set dsResponse.invalidateCache based on that.

        Regardless, use the "long transaction" pattern based on dsRequest.oldValues to detect concurrent modification attempts.

        Comment


          #5
          Dear, Isomorphic thanks for the reply.

          But, unfortunatelly dsResponse.invalidateCache doesn't work... It seems a bug. isn't it?

          If I set dsResponse.invalidateCache to TRUE on server side then on the client side ListGrid's cache isn't resets.

          Comment


            #6
            Please indicate what type of DataSource you are using and show your code for doing this, along with the response you are sending.

            Comment


              #7
              I use WSDataSource.

              There is a server side code of a web service implementation:

              Code:
              public class SmartClientOperationsBindingImpl implements
              		SmartClientOperationsPort {
              	public DSResponse fetch(DSRequest fetchRequest)
              			throws java.rmi.RemoteException {
              
              		DSResponse response = new DSResponse();
              
              		BaseContainer[] documents = CurrencyDocumentRandomGenerator
              				.getInstance().getDocuments();
              
              		int length = fetchRequest.getEndRow().intValue()
              				- fetchRequest.getStartRow().intValue();
              
              		length = length > documents.length ? documents.length : length;
              
              		BaseContainer[] toClient = new BaseContainer[length];
              
              		System.arraycopy(documents, fetchRequest.getStartRow().intValue(),
              				toClient, 0, length);
              
              		response.setData(toClient);
              		response.setStatus(StatusCode.STATUS_SUCCESS);
              		response.setStartRow(fetchRequest.getStartRow());
              		response.setEndRow(fetchRequest.getEndRow());
              		response.setTotalRows(new Long(documents.length));
              		response.setInvalidateCache(Boolean.TRUE);
              
                              System.out.println(" ---------------- " + fetchRequest.getStartRow());
              
              		return response;
              
              	}
              There is a client side code:

              Code:
              ....
              
              final WSDataSource dataSource = new WSDataSource();
                      dataSource.setID("DocumentCurrencyDS");
                      dataSource.setDataFormat(DSDataFormat.XML);
                      dataSource.setDataURL("http://localhost:9080/bars_bdev_webservice/services/SmartClientOperations?wsdl");
                      dataSource.setRecordName("CurencyDocument");        
                      dataSource.addField( new DataSourceIntegerField("docCode"));
                      dataSource.addField( new DataSourceDateField("processingTime"));
                      dataSource.addField( new DataSourceTextField("currencyISO"));
              
                      final ListGrid countryGrid = new ListGrid();
              		countryGrid.setDataSource(dataSource);       
              		countryGrid.setAutoFetchData(true);        
                      countryGrid.setWidth(600);
              		countryGrid.setHeight(400);
                      countryGrid.draw();
              
              ....
              So, when I scrolling to bottom and vice versa to top then I see no more fetch requests in the application server's console. ListGrid has greater than 1000 records.
              Last edited by vkolotov; 11 Mar 2009, 07:15.

              Comment

              Working...
              X