Re: Session Speed / Optimization?? (HD or Memory)

From: Date: Wed, 07 Nov 2001 09:06:46 +0000
Subject: Re: Session Speed / Optimization?? (HD or Memory)
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-73701@lists.php.net to get a copy of this message
For my knowledge, session vars are loaded at each "session_start" and then stored in memory. J "Jason Caldwell" <jason@thinkingman.org> ha scritto nel messaggio news:20011107085958.9386.qmail@pb1.pair.com... > I register some session vars -- say I assign an array to one of my session > vars; like so -- > > <? > session_start(); > session_register("s_myVar"); > > $s_myVar = array("abc","def","ghi","jklm"); // assign > an array to my > session var > > (in_array("abc", $s_myVar)) ? print("true") : print("false"); // > read > $s_myVar from HD ? > (in_array("ghi", $s_myVar)) ? print("true") : print("false"); // > read > $s_myVar from HD, again? > (in_array("12S", $s_myVar)) ? print("true") : print("false"); // > read > $s_myVar from HD, again? > > ?> > > My question is -- since the session var is stored in a session file (on my > hard drive) -- with each of these IN_ARRAY functions, will my hard drive > (or, the session file) be read -- *each time*? -- OR will the session var > $s_myVar load into memory completely right off the bat? > > If I'm doing a bunch of *checking* on an Array or Vars, then, of course, if > I'm hitting my hard drive all the time then performance will become very > bad. > > An *alternative* would be to load the session var into a std memory var, > like so: > > <? > session_start(); > session_register("s_myVar"); > > $s_myVar = array("abc","def","ghi","jklm"); > > $newArray = $s_myVar; // assigning the session array to a non-session > (memory resident) var > > (in_array("abc", $newArray)) ? print("true") : print("false"); > // read > $newArray from memory > (in_array("ghi", $newArray)) ? print("true") : print("false"); > // read > $newArray from memory > (in_array("12S", $newArray)) ? print("true") : print("false"); > // read > $newArray from memory > > ?> > > So, my point (question) is -- I don't know enough about sessions (under the > hood, so to speak) to know if the vars are loaded completely into memory > (first) then processed by all commands, or if they are read in parts > requested by the program (such as in my array example.) > > Thanks. > Jason > >

« previous php.general (#73701) next »