Hello,
Anyone know is there a way that I can create an object, which persists across different users and sessions? Kind of like system wide global static variable ().
The reason is:
I have a data structure (think of category tree) that once constructed, should only be read only by all users in all sessions. Since constructing this object needs multiple database read, and the values are the same for all users (and it is not sensitive data), I guess it would make sense to construct it only once as "system wide" static object.
The only related method I can think of is: construct it and save it to the session, but this is for one session only, not what I want.
Any idea of it?
Thanks.
server wide persistant object?
Moderator: General Moderators
Re: server wide persistant object?
Hi,
Hmm... the only way I can think to do this is to store it something i.e. a database table holding the constructed information which itself only needs one query to return.
Alternatively what about dynamic PHP - write a file containing the object with the data you want as a PHP file then include that into all scripts.
Cheers,
Dave.
Hmm... the only way I can think to do this is to store it something i.e. a database table holding the constructed information which itself only needs one query to return.
Alternatively what about dynamic PHP - write a file containing the object with the data you want as a PHP file then include that into all scripts.
Cheers,
Dave.
Re: server wide persistant object?
You can use global caches like APC or memcache
http://php.net/manual/en/book.apc.php
http://php.net/manual/en/book.memcache.php
http://php.net/manual/en/book.apc.php
http://php.net/manual/en/book.memcache.php