Purpose : ======== High performing extension to store session data in process memory for ZTS enabled php (multithreaded php) Description: ============ Php's default session handler (mod_files) saves the session data in file. To improve performance, we can save the session data in ramdisk or in /tmp/ on Solaris. Even when we store the session data in ramdisk lot of CPU cycles are spent in open/read/write call. This extension allows php to save session date in process memory which is much faster and efficient. If session data is huge then this extension will consume lots of memory. Requirement : ============= * This session is specific to single process multithreaded php. mod_mm provide similar functionality for multiprocess php. * php 5.2.x or 5.3.x Configuration : =============== extension="memession.so" [Session] session.save_handler=memsession session.gc_maxlifetime = 300 Php's session GC will cleanup the old sessions. So session gc time session.gc_maxlifetime should not be very high otherwise it will consume lots of memory. Optional configuration : ------------------------ [Session] memsession.save_path="/var/tmp/memsession.bin" If users want to dump session after server shutdown, this extension can save/restore session data in a file. Compilation : ============== Compiling on unix/linux platforms (for mulithreaded php e.g NSAPI php) ----------------------------------------------------------------- $ phpize $ CFLAGS="-m32" ./configure --with-php-config=/bin/php-config $ gmake $ gmake install Compilation on linux : ---------------------- -march=i586 might be required to enable gcc's atomic operations $ CFLAGS="-m32 -march=i586" ./configure --with-php-config=/bin/php-config Compilation on Windows : ------------------------ * There is no phpize on windows so we need to compile it along with php sources. Create a new directory called "pecl" parent to where the source of php is located, e.g. "C:\pecl\", drop the extension in here ("C:\pecl\memsession\") then compile php using the following: C:\php-src-5.3.0> buildconf C:\php-src-5.3.0> configure --enable-apache2handler --enable-memsession=shared C:\php-src-5.3.0> nmake Other compiler notes : --------------- * gcc 4.1.2 is required on Linux for atomic operations. Works fine on Fedora 11 for 32 bit and 64 bit php. * Windows and Solaris 10 has builtin atomic APIs so no specific compiler is required. * On Windows it works with VC6 and VC9 Source code notes : ==================== zend_atomic.h provides the atomic functions. zend_lock.h provides the read write lock functionality. memsession.c and memsession.h are core extension files.