NetTalk Central

Author Topic: In-memory files and user log outs  (Read 3538 times)

jkunes

  • Newbie
  • *
  • Posts: 18
    • View Profile
    • Email
In-memory files and user log outs
« on: March 23, 2009, 10:23:34 AM »
I am very new to both Nettalk and web applications.  I have examined the webserver examples and I think (hope) I am ready to begin working on my webserver application.  The application uses an MSSql database but I would like to collect some data when the user logs on and store it in in-memory files.  I will need to know when the user logs out so that I can delete the associated records.  I anticipate that there would be no more than 1mb (probably much less) stored in the in-memory files at any one moment, but I am wondering if just deleting the records associated with the session will prevent memory-leaks?  Also, will my application be aware when there is a session time-out?  Is this an appropriate use of in-memory files?  I use in-memory files very often in my windows apps with great success, but I am somewhat concerned about this approach to a webserver app.

Thanks,
Jill

kevin plummer

  • Hero Member
  • *****
  • Posts: 1195
    • View Profile
    • Production Accounting and Software Payroll
Re: In-memory files and user log outs
« Reply #1 on: March 23, 2009, 02:32:49 PM »
Hi Jill,

You may just be able to store what you want in the Session Queue. Check out SetSessionValue and GetSessionValue in the docs. I would just crunch over one of the examples and do some experimenting with this and memory tables. Which ever way you go, your first app is going to be a learning experience but NTW is an awesome product, powerful and flexible to do pretty much whatever you want (within the web limitations) when you learn how.

Good luck!

Cheers,

Kevin

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: In-memory files and user log outs
« Reply #2 on: March 23, 2009, 09:51:36 PM »
Hi Jill,

It's a perfect use of the In-Memory tables - just use the SessionID (p_web.SessionId) as a field to match the "user" to his "records".

Deleteing memory table records when the session ends should be fine. Chances are the memory won't immediately be returned to windows (unless windows "wants" it back) but subsequent records will re-use the same space. So there should be no memory leak.

In the WebServer procedure you can add some code to the _DeleteSession embed point, before the parent call. When this is called a session is being deleted, so you can use this place to delete related records from the Memory table.

As kevin points out you may want to use the SessionQ as an alternative - but either will work fine.

Cheers
Bruce

jkunes

  • Newbie
  • *
  • Posts: 18
    • View Profile
    • Email
Re: In-memory files and user log outs
« Reply #3 on: March 24, 2009, 08:09:04 AM »
Thank you Kevin and Bruce!

I am planning to use in-memory files because I would like to store some info about each user's projects when they login.  Each user could have as many as 25 current projects, hence 25 records in the in-memory table.

The _DeleteSession embed should work well.  I changed the time-out to 1 minute to test and I see that one minute after the client logs out, the _DeleteSession procedure executes.  This should be just fine for my purposes.

I'm having fun with NetTalk so far.  But I am glad to know you folks are available to help.  Thanks again.

Cheers
Jill