Session ? Static ?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • StinkFinger

    Session ? Static ?

    All,
    I have a function that returns data from my db as an array. To reduce the
    times the script
    has to access the db should I store the contents of the variable in a
    session variable and
    access it that way, or should I figure out how to set it and use it as a
    static variable ?

    I was thinking doing an isset on the session var, if exists, use it, if not,
    hit the db and store the
    session var. Also, the data that is stored in the db will not change too
    often, my sessions will
    expire way before that so I dont have to worry about "stale" data.

    Ideas ?


  • Jochen Daum

    #2
    Re: Session ? Static ?

    Hi,

    On Tue, 29 Jun 2004 21:49:26 -0800, "StinkFinge r" <stinky@pinky.c om>
    wrote:
    [color=blue]
    >All,
    >I have a function that returns data from my db as an array. To reduce the
    >times the script
    >has to access the db should I store the contents of the variable in a
    >session variable and
    >access it that way, or should I figure out how to set it and use it as a
    >static variable ?[/color]

    The way to do it is to use the session. However, if this is good,
    depends on the number of users and the way they use the data. The
    session files will be stored on disk and with a wel spread use of your
    database you might end up storing your whole database in session files
    again.

    HTH, Jochen
    --
    Jochen Daum - Cabletalk Group Ltd.
    PHP DB Edit Toolkit -- PHP scripts for building
    database editing interfaces.
    Download PHP DB Edit Toolkit for free. PHP DB Edit Toolkit is a set of PHP classes makes the generation of database edit interfaces easier and faster. The main class builds tabular and form views based on a data dictionary and takes over handling of insert/update/delete and user input.

    Comment

    • StinkFinger

      #3
      Re: Session ? Static ?

      > The way to do it is to use the session. However, if this is good,[color=blue]
      > depends on the number of users and the way they use the data. The
      > session files will be stored on disk and with a wel spread use of your
      > database you might end up storing your whole database in session files
      > again.
      >[/color]

      Thanks for your reply. I think I am going to test the session route. I have
      been playing
      with MySQLs Query Cache and had good luck w/it also.

      I have enabled sessions for one of my modules. The problem I was having,
      was, if someone
      visits SECTION A, all the info for SECTION A is read and displayed. The user
      then goes
      to SECTION B and then back to SECTION A, however, the information is
      constantly re-read
      from the db, even though they were already there. By storing some of the
      information in session
      variables and retrieving them, I think I can increase the overall speed of
      the site.


      Comment

      Working...