Skip to main content
10-Marble
January 19, 2021
Solved

Set Cache Method of remote thing via service

  • January 19, 2021
  • 1 reply
  • 2169 views

I am facing the same problem. I need to set the   to "Read From Server Cache". But I can find no documentation on how this is done. The only thing I have found is a support article (https://www.ptc.com/en/support/article/CS276903) that states that I should use:

 

catcheOptions: "Read from Server Cache",

But that does not work, even if I change the keyword to cacheOptions. Any help would be appriciated!

Best answer by mnarang

I apologies for my above response, it did not work in my previous testing but again tested it with twx 9.1 and it seems to work. You can test it on your instance with this snippet:

 

Things["xyz"].SetRemotePropertyBinding({
propertyName: "abc" /* STRING */,
pushThreshold: 0 /* NUMBER */,
aspects: a /* JSON */,
foldType: undefined /* STRING */,
sourcePropertyName: "LineGroup1--1-1_SinkingEDM--Current" /* STRING */,
timeout: 50 /* INTEGER */,
pushType: "VALUE" /* STRING */,
cacheTime: 0 /* INTEGER */
});

 

Wherein cacheTime can govern your cachemethod so set it like this:

 

-1 : Fetch From Remote every read
0 : Read From Server Cache
above 1 or more > Cached for specific time
 
Please test it and respond it that works. If it does not work please let us know your ThingWorx version.

1 reply

5-Regular Member
January 20, 2021

Currently there is no good way to change remote property aspects(cache method and others) via a service. There is already a discussion going on to implement this in future release.

 

 

mnarang5-Regular MemberAnswer
5-Regular Member
January 20, 2021

I apologies for my above response, it did not work in my previous testing but again tested it with twx 9.1 and it seems to work. You can test it on your instance with this snippet:

 

Things["xyz"].SetRemotePropertyBinding({
propertyName: "abc" /* STRING */,
pushThreshold: 0 /* NUMBER */,
aspects: a /* JSON */,
foldType: undefined /* STRING */,
sourcePropertyName: "LineGroup1--1-1_SinkingEDM--Current" /* STRING */,
timeout: 50 /* INTEGER */,
pushType: "VALUE" /* STRING */,
cacheTime: 0 /* INTEGER */
});

 

Wherein cacheTime can govern your cachemethod so set it like this:

 

-1 : Fetch From Remote every read
0 : Read From Server Cache
above 1 or more > Cached for specific time
 
Please test it and respond it that works. If it does not work please let us know your ThingWorx version.

10-Marble
January 20, 2021

I tested the code and it worked (if I set the aspects to undefined). So the trick was to set the cache time to a specific value to get the correct cache mode. Would be good to get that into the documentation!  Thank's for the help!