cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - You can change your system assigned username to something more personal in your community settings. X

What are the various idea to store temporary data/cache

AP_10343008
15-Moonstone

What are the various idea to store temporary data/cache

I stored infotable data in userextensions which will be moved to datatable once user clicked submit button. 

But updating one infotable userextension property for frequent service execution causing loss of data. 

Any other possible ways are there to store infotable values temporarily?

14 REPLIES 14

As of 9.5.1 you could try to use

TW.sessionStorage.getItem()
TW.sessionStorage.setItem()
 
 
AP_10343008
15-Moonstone
(To:Rocko)

It is working in expression of mashup. But how to execute this from Things>>Services ?

If you need this server side, you can think about transient properties (not persistent, not logged), and you could create your own UserSessionThing which holds those properties, tied to the User and their current session.

AP_10343008
15-Moonstone
(To:Rocko)

Does sessionStorage is user specific ? 
Does the value replaced if multiple users trying in same time ?

It is user specific since the session is too.

Hi AP

 

Have you considered using a DataTable entity?

 

In Composer, you can create a DataTable by associating in to a specific DataShape. In Composer it gives you a UI ("Mashup" tab) to view & modify the data without needing to create a custom Mashup. It also comes with pre-made services, like QueryDataTableEntries and AddDataTableEntry to view and modify the data, you could use those services in a custom Mashup.

 

If you need to separate them by user, you could their default "Source" column, or add a custom User column to the DataShape, or even create a separate entity for each user.

Ofcourse it is user specific data. 
Will it work even if n number of users updating at same time?

As I said, you do have the possibility of creating a different entity for each user. For example TempDataTable_mstarnaud, TempDataTable_AP103343008, TempDataTable_Rocko. You could even manage their permissions so only the related user has access.

 

I'm not an expert on DataTables. But if you're using 1 DataTable shared to everyone, I do think you would have the risk that 2 people may try to modify the same record and one user's changes would override the other user's changes. For example if both users look at the same record, then user #1 deletes the record, and user #2 then tries to update it I'm expecting the update will fail. Which is why in your case using 1 shared DataTable and the default Composer UI may not be the best idea, I would suggest either separating it (1 DataTable per user) and/or making a Mashup that only gets the current user's records.

Two comments on this:

1) in OP they stated data "will be moved to datatable once user clicked submit button" so my understanding is that there already exists a datatable. Not sure if additional Datatables would help in the situation, also as it seems to be temporary data.

2) Datatables per default have a user column which is populated automatically and can be used to filter to avoid data of other users being exposed.

I'm not sure if I understand your question.
Do you have user A using his PC, user B using this same app at different PC? And you want store datas of user A to be storing his own data in such way, it does not influence user B, and vice-versa? So, if user A stores his data, THEN user B store his - it does not overwrite user A data?
Sounds like session info/session parameters. Here you have docu for it: Session Parameters (ptc.com).
But I'm just testing it so can not confirm if it works well. 

Hello @AP_10343008

 

It looks like you have some responses from some community members. If any of these replies helped you solve your question please mark the appropriate reply as the Accepted Solution. 

Of course, if you have more to share on your issue, please let the Community know so other community members can continue to help you.

Thanks,
Community Moderation Team.

Hi @AP_10343008 ,

 

To obtain an effective answer you need to explain in detail the data you're keeping in that User Extension property.

I find it hard to believe that the data is overwritten for a single user just due to frequent service execution, meaning from what I understand, that the user clicked too fast the submit button.

 

Yes. When I am using Infotable property created in user extension, The service updates each row of infotable continously. 
Example: If second row of infotable property updating before first row updation completes, then ill lose first row data. 

If third row started updating in infotable property before second row gets updated, then ill lose second row data.

In this situation (storing the whole infotable) whatever data store you'd use, you would still have this issue.

You need to have a data store that allows you to update separate rows atomically, without affecting the other rows. Infotables are always updated in their entirety, there's no capability to update only a row.

I would suggest the following:

  1. Separate these rows as properties. If your infotable contains maximum let's say 10-20 rows, you can separate these as properties (still on the UserExtension side). You can, or not, make these persistent or not.
  2. Store these rows as items in a DataTable, SQL Table or Stream. I typically do not prefer this because updating these rows (that would also need to have an User column to be User-specific) effectively "hit" the disk, hence always generating I/O - no chance to disable this. If we're speaking about very frequent updates, which it's subjective, you need to be aware and measure the impact on the database.
Announcements


Top Tags