Announcement

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

    How should I configure cacheAllData on a RestDatasource properly?

    Hi there,

    I've defined a RestDataSource with cachAllData=true and an OperationBinding like

    Code:
    .. other bindings here, amonst others, the default fetch operation binding
    ...
    final OperationBinding cacheSyncFetch = new OperationBinding();
    cacheSyncFetch.setOperationType(DSOperationType.FETCH);
    cacheSyncFetch.setOperationId("cacheSync");		cacheSyncFetch.setDataURL(ResourceUtil.getSmartcoreDSBaseURL());
    final DSRequest csReq = new DSRequest();
    Criteria cacheSyncCriteria = getCacheSyncCriteria();
    csReq.setCriteria(cacheSyncCriteria);
    csReq.setHttpMethod("POST");
    cacheSyncFetch.setRequestProperties(csReq);
    ds.addBinding(cacheSyncFetch);
    I want the datasource to use the above operationBinding for the initial cache data request. However, I don't see any possibility to configure the datasource because the Datasource-API does not seem to define an appropriate Java-Setter.
    Setting the attribute directly in the datasource contructor via setAttribute("cacheAllOperationId", "cacheSync") does not seem to have any effect. So how can I tell the datasource to use my CacheSync-OperationBinding?

    Next question: What is the recommended way to drop/refresh the client-side datasource cache?
    Is it right to use datasource.setCacheData(new Record[0]); in order to drop the client side datasource cache for a Datasource with cacheAllData=true? Will the datasource refresh its cache automatically?


    I do NOT use the Smartclient Server Backend.

    I'm Using SmartClient Version: v9.1p_2014-03-05/LGPL Development Only (built 2014-03-05) on the client-side.

    Any advice is appreciated. Thanks in advance.
    Last edited by hmueller; 24 Sep 2014, 01:29. Reason: forgot to mention that are more operation bindings defined for this ds

    #2
    We see the problem with the missing setter setCacheAllOperationId() and we'll fix that.

    A setAttribute() call in your DataSource constructor should definitely have worked. Look closely for a typo, such as using a capital "D" in "Id".

    Setting cacheMaxAge is generally the right way to handle cache invalidation. If you have manual cache updates to individual records, you can apply them via DataSource.updateCache()

    Comment


      #3
      The problem was that cacheAllOperationId and cacheAcrossOperationIds are both marked "RW" but should be "IR". This means that cacheAllOperationId and cacheAcrossOperationIds cannot be modified once the DataSource object has been created, they can only be set on creation time.
      We have fixed the documentation now.

      Comment


        #4
        Ok, thanks for the info. I'll retry...

        Comment

        Working...
        X