"Robert Foster" <[EMAIL PROTECTED]> wrote:
> PHP Sessions are similar to session in ASP, ASP.Net, etc.  Objects within
> the session are serialised into a stream and stored in the specified storage
> medium.  By Default, PHP stores sessions in a file in the /tmp directory,
> identified by a unique filename that is stored in a cookie on the browser if
> it is supported, or encoded onto the URL if not.
> 
> You can also write custom session handlers, allowing you to store the
> session anywhere else including a database.  There is some documentation on
> the Zend.com site for using the Session api, but it's simply a matter of
> writing some functions with specific names, and hooking them in via the php
> configuration.
> 
> As far as storing a memory database, you would need to somehow grab a handle
> to the memory location, keep the database alive between session hits, and
> then re-attach to it.  Alternatively you could create some kind of database
> serialisation method and serialise the database to the session.  It would,
> however, be a lot more efficient to simply create a file-based database in
> the first place and re-open it every time a page is called.
> 

Based on your description above, I would recommend the following
for a session database:

  *  Create a file database with some unique name in /tmp
  *  Open the database for each hit, but immediately set
     PRAGMA synchronous=OFF;

With PRAMGA synchronous=OFF, all of your "disk I/O" is really
just going into your operating systems disk cache - very little if
any of it is actually going to disk.  So you get most of the speed
benefits of a :memory: database.  The reason you do not normally
set PRAGMA synchronous=OFF is because with synchronization off,
you run a very serious risk of database corruption following an
OS crash or power failure.  But for a session database, you don't
care.  If the OS crashes or the power fails, you've lost the
session anyway.
--
D. Richard Hipp   <[EMAIL PROTECTED]>

Reply via email to