Re: Question on Variable Assignment



GS wrote:
"Jerry Stuckle" <jstucklex@xxxxxxxxxxxxx> wrote in message news:gkdhn0$k0t$1@xxxxxxxxxxxxxxxxxxxxxx
GS wrote:
"Jerry Stuckle" <jstucklex@xxxxxxxxxxxxx> wrote in message news:gkcscn$eup$2@xxxxxxxxxxxxxxxxxxxxxx
GS wrote:
I have an object, 'name' that has a number of members. The first time a user visits a page that creates 'name', I check the memcache for it's existance. If not in the memcache, I load the object from the db, and store a copy in the memcache. On any subsequent visit, the copy from memcache ($cache) is found and I then copy it into the object.

Essentially, I retrieve $cache, and then set $this to it the following way...

$this->method1 = $cache->method1
$this->method2 = $cache->method2
.
.
.
$this->methodn = $cache->methodn

As I may change these methods, it seems a little cumbersome. I have tried setting $this = $cache, $this =& $cache, but it doesn't work (and I get no error generated, even with error reporting and display set to on in php.ini.

Any quick way to do this, other then setting method values on a one-to-one basis as I am currently doing?

Thanks again!


Why are you even worrying about caching the object? Just load it from the database as necessary.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@xxxxxxxxxxxxx
==================


Due to the fact that loading this particular object, on creation, contains a large amount of varied data that requires ~10 trips to the db, caching is much much faster. Saves db traffic, reduces user wait times, etc etc.

Contains data which may be obsolete...

If you have an object which requires 10 database requests to fill, you have a major design problem - either in your database or your code. Even my most complex objects have never required that many database calls.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@xxxxxxxxxxxxx
==================


When the relevent data is updated (~monthly), the object is refreshed in the memcache, so the cached obj is always up-to-date.

The object in question is a name entry ie 'Bill'.

It contains:

db query #1
- meaning, pronunciation, origins, syllables, times viewed, addition date, name rating

db query #2
- similar sounding names

db query #3
- user submitted nicknames

db query #4
- names derived from this name (child names)

db query #5
- names that this name is derived from (parent names)

db query #6
- user comments for this name

db query #7
- popularity of this name in the United States, by year (used to display a chart)

So 7, not 10. I've combined as many queries as possible to the point where I COULD combine a couple more using a more complicated query, but the cost of doing so is more expensive (the more complicated single query takes longer than doing two seperate ones).

The caching is really working quite well honestly, but I did spend countless hours trying to reduce queries...



Still like a lot of unnecessary work to me. If performance is your concern, then with proper design you should be able to do everything in one query.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@xxxxxxxxxxxxx
==================
.



Relevant Pages

  • Re: Slow form, again
    ... subforms if you think the problem might lie there. ... Is the below query what the Parent form is based on? ... Removing all subforms gets the form to load in about 15 seconds. ... If it's not my database I'm not sure what to tell my co-workers and boss ...
    (microsoft.public.access.tablesdbdesign)
  • Re: Slow form, again
    ... Segment: Control Source Business_Segment/Row Source ... Is the below query what the Parent form is based on? ... Removing all subforms gets the form to load in about 15 seconds. ... If it's not my database I'm not sure what to tell my co-workers and boss ...
    (microsoft.public.access.tablesdbdesign)
  • Re: Slow form, again
    ... Thanks everyone for the posts. ... It is over a LAN and the form is bound to a query. ... Removing all subforms gets the form to load in about 15 seconds. ... database, and same brick wall! ...
    (microsoft.public.access.tablesdbdesign)
  • Re: Slow form, again
    ... database, and same brick wall! ... seconds to load. ... My form pulls off a query (query takes about 10 ... "Delete the SQL from the RecordSource and RowSource properties ...
    (microsoft.public.access.tablesdbdesign)
  • Re: Slow form, again
    ... Is the below query what the Parent form is based on? ... Removing all subforms gets the form to load in about 15 seconds. ... database, and same brick wall! ... "Delete the SQL from the RecordSource and RowSource ...
    (microsoft.public.access.tablesdbdesign)