Session Speed / Optimization?? (HD or Memory)

From: Date: Wed, 07 Nov 2001 08:59:58 +0000
Subject: Session Speed / Optimization?? (HD or Memory)
Groups: php.general 
Request: Send a blank email to php-general+get-73700@lists.php.net to get a copy of this message
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 (#73700) next »