Re: application-wide shared data/object

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Aiguo Fei wrote:
> Thanks your insightful comments. Clearly scalability is a concern for large
> scale applications. One has to be discreet with it if such a facility is
> available. For the dictionary example, I feel it definitely can use such a
> facility and DB approach is much slower; and scalability/load balancing is
> not an issue since no synchronization of any kind is necessary.
> 
> I checked APC, but unfortunately it doesn't have any documentation; there is
> a short section on it in "Essential PHP Tools", but appears to be too out of
> date. I checked out the chapter on PHP extentions in "Power PHP5
> programming" book, seems "persistent resource that can survive in between
> requests" seems to do what I have in mind, but again there is no more than
> just mentioning it.

Not much documentation is needed:

  if(!$dict = apc_fetch('dict')) {
    $dict = function_that_returns_a_dictionary_array_or_object();
    apc_store('dict',$dict);
  }

That's all.  Now you are working with a $dict array or object from
shared memory.  If it isn't in shared memory you create it and put it
there, so typically that will only happen on th every first request.
apc_store() has an optional 3rd argument which is the timeout in seconds
for the cache entry.

-Rasmus

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux