Refresh single table in all clients

Questions and Answers on installation, deployment, management, locking, tranasactions of Servoy Application Server

Refresh single table in all clients

Postby steve1376656734 » Tue Jan 24, 2023 6:50 pm

Hi,

I have an stored procedure that updates a single table in the DB. The process may update any number of records each time it runs and it is run from within a Servoy program.

Is there a way for the client that has just run this program to signal all attached clients that their cached records for that table (and only that table) are now invalid and should be refreshed? I can see that the entire data cache can be flushed from the Servoy admin page but I want to do it for a single table and from within a Servoy program.

Thanks
Steve
Steve
SAN Developer
There are 10 types of people in the world - those that understand binary and those that don't
steve1376656734
 
Posts: 309
Joined: Fri Aug 16, 2013 2:38 pm
Location: Lanzarote

Re: Refresh single table in all clients

Postby swingman » Wed Jan 25, 2023 12:29 am

Maybe this will work: if you have a way of recognising the updated records, you can load them into a foundSet and refresh this foundSet from the database using the databaseManager...
Christian Batchelor
Certified Servoy Developer
Batchelor Associates Ltd, London, UK
http://www.batchelorassociates.co.uk

http://www.postgresql.org - The world's most advanced open source database.
User avatar
swingman
 
Posts: 1443
Joined: Wed Oct 01, 2003 10:20 am
Location: London

Re: Refresh single table in all clients

Postby mboegem » Wed Jan 25, 2023 9:16 am

Hi Steve,

to signal all clients to refresh the data of a certain table, you can use:
Code: Select all
plugins.rawSQL.flushAllClientsCache(_sServerName, _sTableName)

Depending on the usage of the table, it can be a heavy operation.

Another way to make sure users see the latest data is by using:
Code: Select all
databaseManager.refreshRecordFromDatabase(_fs, -1)

Downside of this function is that it will only refresh the records for the client on which is it is executed.
I've used this in the past for refreshing data coming from a database view.
So each time the user entered a form using this view, data would be refreshed.
Because the datasource (db view) was immutable anyway, this method worked fine for the situation.

Hope this helps
Marc Boegem
Solutiative / JBS Group, Partner
• Servoy Certified Developer
• Servoy Valued Professional
• Freelance Developer

Image

Partner of Tower - The most powerful Git client for Mac and Windows
User avatar
mboegem
 
Posts: 1660
Joined: Sun Oct 14, 2007 1:34 pm
Location: Amsterdam

Re: Refresh single table in all clients

Postby steve1376656734 » Wed Jan 25, 2023 10:38 am

@Christian - that would work but the table has 2 million records and I have no way of knowing which records are updated so even just loading the foundset would be an expensive operation

mboegem wrote:
Code: Select all
plugins.rawSQL.flushAllClientsCache(_sServerName, _sTableName)


That is perfect as each client would only have a few records loaded from that table at a time so it would be trivial for their client to reload them - thanks Mark
Steve
SAN Developer
There are 10 types of people in the world - those that understand binary and those that don't
steve1376656734
 
Posts: 309
Joined: Fri Aug 16, 2013 2:38 pm
Location: Lanzarote

Re: Refresh single table in all clients

Postby swingman » Wed Jan 25, 2023 11:01 am

I have a similar situation, but I have a field in the table called needs refresh and the outside process flags the report that servoy needs to load.
Christian Batchelor
Certified Servoy Developer
Batchelor Associates Ltd, London, UK
http://www.batchelorassociates.co.uk

http://www.postgresql.org - The world's most advanced open source database.
User avatar
swingman
 
Posts: 1443
Joined: Wed Oct 01, 2003 10:20 am
Location: London


Return to Servoy Server

Who is online

Users browsing this forum: No registered users and 2 guests

cron