NetTalk Central

Author Topic: Memory files in webserver  (Read 3663 times)

JohanR

  • Sr. Member
  • ****
  • Posts: 375
    • View Profile
    • Email
Memory files in webserver
« on: November 26, 2010, 07:12:12 AM »

Hi,

1)
I need to have a memory file for general data throughout the webserver.
Where is the correct embed to open the file, without it being closed so that it will remain open throughout all procedures and sessions.

It should only get closed once the webserver is shutdown.
This will be similiar to the session queue, except it will be handling app data across threads and across differnt users logged in.

thanks

Johan




Alberto

  • Hero Member
  • *****
  • Posts: 1873
    • MSN Messenger - alberto-michelis@hotmail.com
    • View Profile
    • ARMi software solutions
    • Email
Re: Memory files in webserver
« Reply #1 on: November 26, 2010, 10:30:43 AM »
Hi Johan,

WebServer proc, be sure the file in NOT threaded.

Cheers
Alberto
-----------
Regards
Alberto

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11251
    • View Profile
Re: Memory files in webserver
« Reply #2 on: November 26, 2010, 10:43:28 AM »
>> Where is the correct embed to open the file, without it being closed so that it will remain open throughout all procedures and sessions.

wrong

>> WebServer proc, be sure the file in NOT threaded.

very, very wrong. What Alberto meant here was that while the file must be THREADED it must share the data across threads - so make sure you are not using the /THREADEDCONTENT switch. Making the file itself non-threaded would mean a shared record buffer, and that would be _very_ bad in a multi-threaded environment.

Back to Johan's question;

>> Where is the correct embed to open the file, without it being closed so that it will remain open throughout all procedures and sessions.

The mistake here is in treating the memory table different to any other table. For purposes of use, the fact it is a Memory driver should not matter. Indeed if it helps you, think of the table as a TPS table. Or perhaps a TPS-table-on-a-RAM disk.

Specifically;
a) the table needs to be opened (and if you like closed) on each thread where it's used.
b) closing the table does _not_ empty it.
c) if you use a variable file name, you can have multiple tables containing different data.

Treat it _exactly_ like any other table, and you'll be on the right track.

cheers
Bruce



JohanR

  • Sr. Member
  • ****
  • Posts: 375
    • View Profile
    • Email
Re: Memory files in webserver
« Reply #3 on: November 26, 2010, 09:01:32 PM »
Hi Bruce and Alberto

Thanks Alberto, I knew what you meant and had that part done.

Thanks Bruce, as always a very detailed and clear reply.

I always knew that memory files do not lose their data if you close them, I had a different problem, but everything pointed to the memory file not having the data in it.
As it happens most times you dive into the wrong direction and then doubted and thought that memory files lose their records if you close them.

Found the problem and fixed it, it was not memory table related.

thanks for assistance

Johan