WordPress » D.J. imag1
 
 
总有你想不到的东西

session-set-save-handler.php

session_set_save_handler

(PHP 4, PHP 5)
session_set_save_handler — Sets user-level session storage functions
Description
bool session_set_save_handler ( callback open, callback close, callback read, callback write, callback destroy, callback gc )

session_set_save_handler() sets the user-level session storage functions which are used for storing and retrieving data associated with a session. This is most useful when a storage method other than those supplied by PHP sessions is preferred. i.e. Storing the session data in a local database. Returns TRUE on success or FALSE on failure.

Note: The “write” handler is not executed until after the output stream is closed. Thus, output from debugging statements in the “write” handler will never be seen in the browser. If debugging output is necessary, it is suggested that the debug output be written to a file instead.

The following example provides file based session storage similar to the PHP sessions default save handler files. This example could easily be extended to cover database storage using your favorite PHP supported database engine.

Read function must return string value always to make save handler work as expected. Return empty string if there is no data to read. Return values from other handlers are converted to boolean expression. TRUE for success, FALSE for failure.

matt at openflows dot org
19-Sep-2006 08:02

Note that for security reasons the Debian and Ubuntu distributions of php do not call _gc to remove old sessions, but instead run /etc/cron.d/php*, which check the value of session.gc_maxlifetime in php.ini and delete the session files in /var/lib/php*. This is all fine, but it means if you write your own session handlers you’ll need to explicitly call your _gc function yourself.

http://xoops.org.cn/modules/newbb/viewtopic.php?topic_id=10736

请部xoops_session是管什么的,我这个表里插入的数据竟有12M之多,能不能删除?如何能让它不再增肥?

近日工作重点
  • XOOPS 通用性结构管理,adjacency tree <-----> preorder tree
  • AJAX in XOOPS
  • XOOPS membership extension
  • Investigation: eCommerce upon XOOPS
  • What to tune in MySQL Server after installation

    By Peter Zaitsev, September 29, 2006

    My favorite question during Interview for people to work as MySQL DBAs or be involved with MySQL Performance in some way is to ask them what should be tuned in MySQL Server straight after installation, assuming it was installed with default settings.

    I’m surprised how many people fail to provide any reasonable answer to this question, and how many servers are where in wild which are running with default settings.

    Even though you can tune quite a lot of variables in MySQL Servers only few of them are really important for most common workload. After you get these settings right other changes will most commonly offer only incremental performance improvements.

    key_buffer_size - Very important if you use MyISAM tables. Set up to 30-40% of available memory if you use MyISAM tables exclusively. Right size depends on amount of indexes, data size and workload - remember MyISAM uses OS cache to cache the data so you need to leave memory for it as well, and data can be much larger than indexes in many cases. Check however if all of key_buffer is used over time - it is not rare to see key_buffer being set to 4G while combined size of .MYI files is just 1GB. This would be just a waste. If you use few MyISAM tables you’ll want to keep it lower but still at least 16-32Mb so it is large enough to accommodate indexes for temporary tables which are created on disk.

    innodb_buffer_pool_size This is very important variable to tune if you’re using Innodb tables. Innodb tables are much more sensitive to buffer size compared to MyISAM. MyISAM may work kind of OK with default key_buffer_size even with large data set but it will crawl with default innodb_buffer_pool_size. Also Innodb buffer pool caches both data and index pages so you do not need to leave space for OS cache so values up to 70-80% of memory often make sense for Innodb only installations. Same rules as for key_buffer apply - if you have small data set and it is not going to grow dramatically do not oversize innodb_buffer_pool_size you might find better use for memory available.

    innodb_additional_pool_size This one does not really affect performance too much, at least on OS with decent memory allocators. Still you might want to have it 20MB (sometimes larger) so you can see how much memory Innodb allocates for misc needs.

    innodb_log_file_size Very important for write intensive workloads especially for large data sets. Larger sizes offer better performance but increase recovery times so be careful. I normally use values 64M-512M depending on server size.

    innodb_log_buffer_size Default for this one is kind of OK for many workloads with medium write load and shorter transactions. If you have update activity spikes however or work with blobs a lot you might want to increase it. Do not set it too high however as it would be waste of memory - it is flushed every 1 sec anyway so you do not need space for more than 1 sec worth of updates. 8MB-16MB are typically enough. Smaller installations should use smaller values.

    innodb_flush_logs_at_trx_commit Crying about Innodb being 100 times slower than MyISAM ? You probably forgot to adjust this value. Default value of 1 will mean each update transaction commit (or each statement outside of transaction) will need to flush log to the disk which is rather expensive, especially if you do not have Battery backed up cache. Many applications, especially those moved from MyISAM tables are OK with value 2 which means do not flush log to the disk but only flush it to OS cache. The log is still flushed to the disk each second so you normally would not loose more than 1-2 sec worth of updates. Value 0 is a bit faster but is a bit less secure as you can lose transactions even in case MySQL Server crashes. Value 2 only cause data loss with full OS crash.

    table_cache - Opening tables can be expensive. For example MyISAM tables mark MYI header to mark table as currently in use. You do not want this to happen so frequently and it is typically best to size your cache so it is large enough to keep most of your tables open. It uses some OS resources and some memory but for modern hardware it is typically not the problem. 1024 is good value for applications with couple hundreds tables (remember each connection needs its own entry) if you have many connections or many tables increase it larger. I’ve seen values over 100.000 used.

    thread_cache Thread creation/destructions can be expensive, which happen at each connect/disconnect. I normally set this value to at least 16. If application has large jumps in amount of concurrent connections and I see fast growth of
    Threads_Created variable I boost it higher. The goal is not to have threads created in normal operation.

    query_cache If your application is read intensive and you do not have application level caches this can be great help. Do not set it too large as it may slow things down as its maintenance may get expensive. Values from 32M to 512M normally make sense. Check it however after a while and see if it is well used. For certain workloads cache hit ratio is lower than would justify having it enabled.

    Note: as you can see all of these are global variables. These variables depend on hardware and mix of storage engines, while per session variables are typically workload specific. If you have simple queries there is no reason to increase sort_buffer_size even if you have 64GB of memory to waste. Furthermore doing so may decrease performance.
    I normally leave per session variable tuning to second step after I can analyze workload.

    P.S Note MySQL distribution contains bunch of sample my.cnf files which may be great templates to use. Typically they would already be much better than defaults if you chose correct one.

    SWiK-Source

    WIKI + TAG + OpenSource

    SWiK-Source is the source code of the swik.net core engine. It is licensed for distribution under the GNU General Public License v2.

    SWiK-Source is meant for people who are curious about the code that powers SWiK, for people who want to try making their own SWiK for their internal use or for some new web site, as well as for use with SourceLabs’ internal and partnering projects.

    SourceLabs has released SWiK-Source as a source code release rather than a packaged release: it’s a complicated system built with a lot of assumptions for custom production servers rather than arbitrary or generic systems.

    SWiK Source is built on and integrated with the platform combination of PHP, MySQL, and Apache HTTPd. These applications are not packaged as part of the distribution, however SWiK Source requires these and other 3rd party open source components to run properly.
    List of components you must either have or obtain and install before setting up SWiK Source:

    1. PHP 5.0 (see below for specific configure line)
    2. Apache 2.0
    3. MySQL 4.1
    4. Ruby
    5. Java
    6. libxml
    7. libjpg
    8. libpng

    Applications of Open Source CMS (3) - eWEEK: Open Source in the Enterprise

    Jim Rapoza, Director of eWEEK Labs published their evaluation results on chosen stacks of portals and enterprise CMSes:

    eWEEK Labs Bakeoff: Open Source Versus .Net Stacks

    Pure Open Source:

    • LAMP - XOOPS on Linux, Apache, MySQL and PHP
    • Linux J2EE - Liferay on Cent-OS Linux, Apache, Tomcat, H2 Database
    • Linux JBoss - JBoss on CentOS with MySQL
    • Linux Python - Zope/Plone on SUSE Enterprise Linux

    Mixing Windows and open source:

    • XOOPS on Windows Server 2003, Apache, MySQL, PHP
    • Plone on Windows Server 2003 R2
    • JBoss and MySQL on Windows Server 2003

    (阅读全文…)