Skip to main content
17-Peridot
September 23, 2020
Solved

Is it possible to cache Javascript object in Thingworx ?

  • September 23, 2020
  • 2 replies
  • 1804 views

Hi, 

I'm going to  implement the following logic for a tree: 

1.   Read the tree node from database Table 

2.   Convert the flat table entries into  a javascript object which has pointers: left, next , parent

3.   Traverse the javascript object to get the children by level. 

 

Since the tree node in database table won't change frequently , I want cache the result of step 2#.  How to where can I store a Javascript object in ThingWorx ? 

 

Regards,

Sean

 

Best answer by SwapnilP

I think you should create one datashape with infotable datatype to store your javascript object.

 

Add that datashape in user management subsystem In the User Session Shape Settings section. The default Thing Shape is GlobalSessionProperties.

 

You can utilise session value as a cache. There are other settings to increase idle  session timout etc.

 

Hope this is useful.

2 replies

22-Sapphire I
September 23, 2020

My first question would be, could you use a network instead?

As far as caching the information. You could store the information as an InfoTable or JSON object and that can easily be kept in memory.

seanccc17-PeridotAuthor
17-Peridot
September 23, 2020

@PaiChung ,

 

network has some gaps for my needs: 

1.   I need services  GetBaseNodes and GetChildrenByDepth(from, to), "network" doesn't seem to  provide these service. 

2.   Does network fetch children everytime from data table ?  if so , I'm afraid of the performance loss, and that's why I want to cache them.  

 

Storing the information as InfoTable or JSON mean  the Javascript tree node object needs to be rebuilt every time when using it ,  it's not so ideal. 

 

Regards,

Sean

SwapnilP13-AquamarineAnswer
13-Aquamarine
September 23, 2020

I think you should create one datashape with infotable datatype to store your javascript object.

 

Add that datashape in user management subsystem In the User Session Shape Settings section. The default Thing Shape is GlobalSessionProperties.

 

You can utilise session value as a cache. There are other settings to increase idle  session timout etc.

 

Hope this is useful.