NetTalk Central

Author Topic: Session queue and value queue  (Read 6232 times)

Rhys Daniell

  • Newbie
  • *
  • Posts: 34
    • View Profile
Session queue and value queue
« on: July 23, 2007, 12:39:11 AM »
Hi everyone good to find this spot. A couple of 'newbie' questions

- what's the difference between the session queue and the value queue?

- is it safe to assume that the p_web.FileToSessionQueue method keeps a full copy of a record?

- what's the life of these queues? i.e. if the user is inactive for some period of time, do they vanish?

Tx
Rhys

PS nice work, JH!


Alan Telford

  • Jr. Member
  • **
  • Posts: 81
    • View Profile
Re: Session queue and value queue
« Reply #1 on: July 23, 2007, 01:50:02 PM »
I'll have a go and leave it to others to correct me.

The session queue is permanent (like global data).
It lasts for the lifetime of the session.
A session will timeout after 15 minutes (configurable on extension template).

A value queue is more like local procedure data.
It contains values from the current page being viewed, and the current URL.
eg. if your url has ?action=view&field=abc&other=dothis

then you will get 3 entries in the value queue.
action=view
field=abc
other=dothis

So, if you ever need to check what was passed on the URL, then you can just check the ValueQueue.

Regards,
Alan

Rhys Daniell

  • Newbie
  • *
  • Posts: 34
    • View Profile
Re: Session queue and value queue
« Reply #2 on: July 23, 2007, 03:18:10 PM »
Thanks, Alan!

Extrapolating ..
- the session queue is available to all pages in this session
- the value queue is only available in the current page

Correct?

Alan Telford

  • Jr. Member
  • **
  • Posts: 81
    • View Profile
Re: Session queue and value queue
« Reply #3 on: July 23, 2007, 03:47:36 PM »
Rhys

That's my understanding.

Also, from what I understand, current page means what's currently open now.
If you refetch the current page, then that is a new page.
The session queue will always be valid (until session timeout).
Apart from getting parameters from the URL line I haven't used the value queue.

Alan

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11181
    • View Profile
Re: Session queue and value queue
« Reply #4 on: August 01, 2007, 12:56:28 AM »
Hi Rhys,

>> the value queue is only available in the current page

a better description might be
"the value queue is only available in the current thread"

A page may make many (asynchronous) requests to the server. Or (like on a form) it may "pop out" to do a lookup, then "come back". These are all new threads, so the Value queue isn't available in these.

As a rule, if you are using parameters on a URL, always save them to the Session Q, and use the Session Q values in any activity. To save the values you can do

p_web.StoreValue('whatever')

This is equivalent to
if p_web.IfExistsValue('whatever')
  p_web.SetSessdionqueue('whatever',p_web.GetValue('whatever'))
end

Cheers
Bruce


Rhys Daniell

  • Newbie
  • *
  • Posts: 34
    • View Profile
Re: Session queue and value queue
« Reply #5 on: August 01, 2007, 04:51:20 PM »
>> p_web.StoreValue('whatever')

So,
Whatever = p_web.RestoreValue('whatever')
to get the value back again?

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11181
    • View Profile
Re: Session queue and value queue
« Reply #6 on: August 01, 2007, 11:03:00 PM »
Hi Rhys,

No, a better way to get it back is simply to use it "as is" in the session queue. In other words, once it is in the Session Queue, then that's most likely the place you want to use it.

The RestoreValue method is usually used to get the "best" value for a variable. It looks first for a Value parameter and uses this if it exists, and if not falls back on the Session Queue. If neither exist then the variable is EVALUATED. (The Evaluate bit only applies if the variable has been bound).

While RestoreValue is a short-cut in some places, it is unnecessary if you did a StoreValue. If you didn't do a StoreValue then you'll have problems elsewhere anyway. If you did do a StoreValue then a GetSessionValue (or GSV) is fine.

Cheers
Bruce