Community Tip - Did you get called away in the middle of writing a post? Don't worry you can find your unfinished post later in the Drafts section of your profile page. X
Greetings,
I have a remote property "Temperature" bound to a property on a VirtualThing. I want the value to be pushed to the server every time and the corresponding Remote Thing to read from property cache to avoid fetching the value each time. I have the cacheTime set to zero and pushType to ALWAYS.
My edge code updates the property every 3 seconds with some random value...however, when i refresh the property values on the Remote Thing in Thingworx, they never change. If i change the cacheTime to a value greater than zero...such as 1000, the values are reflected when i refresh the property values. I understand this is because after 1 second, the value expires in the cache and i suppose at that point is fetches a new value.
// This property is setup for collecting time series data. Each value
// that is collected will be pushed to the platform from within the
// processScanRequest() method.
@ThingworxPropertyDefinition(name="Temperature",
description="The device temperature",
baseType="NUMBER",
aspects={"dataChangeType:NEVER",
"dataChangeThreshold:0",
"cacheTime:0",
"isPersistent:FALSE",
"isReadOnly:TRUE",
"isFolded: FALSE",
"pushType:ALWAYS",
"defaultValue:-999"}),
I suppose a cacheTime of -1 means always fetch from the edge.
I guess i thought that the cache would get updated by the data push and therefore the Remote Thing would only ever have to read from the cache.
Apparently this is not what happens.
There is a related post here: Setting a remote property from the edge
as far as I can tell you have this correct.
with a Push type of Value or Always, the device should be writing the value to the platform every time either when it scans or when the scan runs and the value has changed at the device side.
On the platform you should just set it to Always Read From Cache (I think it may say Read from Server Cache) this means you are depending on the Push from Device to Platform and you will never go to the device to fetch the value, when you are reading the property value on the platform.
Hi Pai,
For some reason, my Temperature property is not getting updated.
Here are the annotations:
@ThingworxPropertyDefinition(name="Temperature",
description="The device temperature",
baseType="NUMBER",
aspects={"dataChangeType:NEVER",
"dataChangeThreshold:0",
"cacheTime:0",
"isPersistent:FALSE",
"isReadOnly:TRUE",
"isFolded: FALSE",
"pushType:ALWAYS",
"defaultValue:-999"}),
I can see the values sending updates on the server, but when i refresh the properties there are no changes.
Here are the attributes in composer:
If i change the cacheTime to a positive value like 1, then it picks up the values from the cache.
Seems that you have to set a cacheTime value > 0 to see values refresh. I believe this means that if the value in the cache has expired, it will fetch from the Virtual Thing. This is not the behavior i want. I only want the values read from the cache.
What am i doing wrong?
I'm using Thingworx Edge SDK 6.0.0 and Thingworx 7.2.
/robert
Can you remove Read Only please and see if that makes a difference?
Even though read only might imply you can write to it from anywhere, since it is bound, it should only be reading from the device.
Thanks!
No change in behavior. Still doesn't appear to be picking up the changes. I don't know if the cache isn't updating or if its just not reading from the cache...either way, the value remains at -999 (same as default value)
I think , making cache time to -1 and increasing the data Change threshold to some integer like 1000 , can make it work .
Is data Change threshold is to be used to record how many times data has been changed or kind of ?
Nope...setting cacheTime = -1 will cause the RemoteThing to fetch from the VirtualThing on each value request. That's not what i want. I just want the RemoteThing to read from the property cache and the VirtualThing to push to the property cache.
dataChange threshold controls when a data change event occurs on the platform. It works in conjunction with dataChangeType.
Has nothing to do with how the platform retrieves data for a property.
Hi Robert ,
I Would like to give a detailed description of how Cache Time works , I believe that will help you understand as if whats happening here. I think System is Working as designed we can configure cache time to get what we want.
If you want Remote Thing to read from Property cache , you will have to cache that value , which as you rightly said will be decided by the time mentioned in Cache time.
Cache Time in little detail :
cacheTime — Tells the ThingWorx server how to behave when reading a remote property. This parameter can take the following values:
-1 — Indicates that the VirtualThing always sends its value, and the server should never request it from the remote application. The value returned always comes from the in-memory cache of the server. Use this value for properties that are configured to be pushed to the server.
0 — Indicates that every time the server uses the value, it should request it from the VirtualThing.
Any other positive value — Indicates that the server should cache the value for that many seconds and then retrieve it from the VirtualThing only after that time expires.
This setting is important for properties that may be accessed frequently by many users. For example, if 100 users attempt to access a property value within a 10 second period, you may want to set this value to 30 seconds. That would ensure that only a single request for the property is sent to the edge every 30 seconds. However, the value returned by the platform could be out of date by up to 30 seconds.
Please share your thoughts as I think behavior, you are witnessing from Thingworx is Normal .
Robert , I think there was slight confusion which I understood now , With Cache time = 0 , the values in Remotething on Thingworx server should change , and if its not changing with cache time = 0 , it and its changing with cache time greater than few seconds , it could be related to some other factor like server taking time to update property value directly from Edge, as the new values getting pushed every time .