I am creating a large multi-server app. My php running under Apache communicates through TCP/IP to a data server on another machine. To increase performance I cache a lot of data in associative arrays that I store in session variables so that it persists between pages. This requires all that data to be be serialized/unserialized at each page display. Also, my app is multi-user. It would be great if I didn't need to go to the data server for data that has already been cached by another user.
Are there any libraries or features that would allow in-memory variables to be scoped to the Apache server level so that they can be shared between sessions and also to avoid session serialization? Obviously, a shared semaphore or locking is required to prevent conflicts.
Thanks!!
Sharing variables between sessions on same server
Moderator: General Moderators
Re: Sharing variables between sessions on same server
Why are you serializing the arrays? They'll work just fine if you place them right in $_SESSION.
It looks like what you want is a data cache on the webserver so it doesn't need to access the data server. I know this kind of goes against the point of having a separate data & web server, but why not store the data you want to cache on the web sever?
It looks like what you want is a data cache on the webserver so it doesn't need to access the data server. I know this kind of goes against the point of having a separate data & web server, but why not store the data you want to cache on the web sever?
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
Re: Sharing variables between sessions on same server
I am not serializing the arrays myself. I AM putting them in $_SESSION, which is automatically serialized by PHP.
My data server is a semantic data server/inference engine. In addition to saving transmission delay, caching also eliminates re-inferencing. A local copy of the data server is not sufficient, I'd like to keep the data in PHP variable form between page sends.
My data server is a semantic data server/inference engine. In addition to saving transmission delay, caching also eliminates re-inferencing. A local copy of the data server is not sufficient, I'd like to keep the data in PHP variable form between page sends.
-
WebbieDave
- Forum Contributor
- Posts: 213
- Joined: Sun Jul 15, 2007 7:07 am
Re: Sharing variables between sessions on same server
If your configuration affords APC, you can look into apc_store and related functions.
Re: Sharing variables between sessions on same server
PHP doesn't exist between page sends. You'll have to store the data outside of a PHP variable.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
Re: Sharing variables between sessions on same server
APC IS the solution. Thank you very much for the help!!
It allows data to be cached and shared between users. It has limitations -- the cached data needs to have a simple structure -- but serialization before storing solves that.
The data is stored under keys. I can use my object ID as the key. This way I only need to unserialize/serialize the specific objects I need rather than the whole $_SESSION.
It allows data to be cached and shared between users. It has limitations -- the cached data needs to have a simple structure -- but serialization before storing solves that.
The data is stored under keys. I can use my object ID as the key. This way I only need to unserialize/serialize the specific objects I need rather than the whole $_SESSION.
Re: Sharing variables between sessions on same server
i also think APC should be a good choice