Jason Hect wrote:

I'm curious about what everyone thinks is the best practice and/or the trade
offs between using session variables against writing information to the
datafile?  In case it makes any difference, I'm using 4D client as the
webserver and running it from native 4D (as opposed to ITK)

Currently I'm trying to limit the number of queries by putting as much as
possible into session variables.  When a user initially logs into the site,
I do most of my queries to get all the pertinent information I might need
and load it all into session variables.  For the most part, the only time I
have to query back to the database is to display/add/del/modify their
shopping cart.  In which case I have to query an Order and a Line Item
table.  I'm wondering if I might be better off performance wise if I stored
all this in session arrays?  I realize it would take more memory on the
webserver, but memory is cheap and I can always add a second 4D client
running the webserver and distribute the load.  Conversely, if I bog the
server down with too many queries, there is no easy fix or alternative.

How does everyone else handle this?  Or I'm I worrying about a non-issue?
Just to put this in perspective, management is telling me to figure on about
15,000 orders per year on this site.  Distributed evenly over the whole year
it doesn't seem too bad, but I'm worried about what happens if 10 or 20
users all log on at the same time...

Thanks,
Jason

Jason,

Unless I can demonstrate that running queries on demand is going to severely affect the user experience, or I know that information that I cache will truly be static, I always run them on demand. If my queries aren't fast enough I optimize at the database end. The problem with storing complete record results in session data (or any other form of cache) is the potential that the user won't be working with current data. User A loads record 1, If user B comes along loads record 1 and changes field 2, and user A later changes field 1 there is a potential for User A to clobber User B's changes since field 2 will be written with its original value (unless you've implemented an optimistic record locking or record versioning strategy).

Also if I were to store a lot of session data I'd probably want to store it in the database and probably in an ObjectTools object. My Active4D session data would simply be a key that I could use to quickly retrieve the OT data.

my .02,

Brad Perkins
_______________________________________________
Active4D-dev mailing list
[email protected]
http://mailman.aparajitaworld.com/mailman/listinfo/active4d-dev
Archives: http://mailman.aparajitaworld.com/archive/active4d-dev/

Reply via email to