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.

    自由软件开发工具
    Line56.com 2006年9月20日的专题文章,”Free Software Development Tools”,介绍了Sourceforge上最流行的10款自由软件开发工具:Gaim, Dev-C++, JBoss, MinGW, CvsGui, Miranda, XOOPS, jEdit, wxWidgets

    Free Software Development Tools
    Here are descriptions of, and links to, the most popular free software development tools on Sourceforge

    by Tamina Vahidy, Line56
    Wednesday, September 20, 2006

    Sourceforge.net is a repository of free open source software, and a lot of it applies to e-business. We’ve compiled this list of the top 10 most popular software development tools available on the site. Click on the product name to get more information and download links straight from Sourceforge.

    (阅读全文…)

    XOOPS 多用户 blog 的实现

    “多用户Blog“是热点关键词

    多用户/单用户的区分本身就是歧义的,可能含义包括:

    1 每个用户有自己完全独立的blog,拥有完整的管理权限。这一类的blog程序以lifetype(plog)和b2e为代表,还有半吊子的 wp-mu。

    2 每个用户有自己独立的显示页面,但只对自己的blog有管理权,对界面、分类等只有使用权。这一类应该说不算一个独立的分类,至多算是对单用户blog的改动(hack)。

    3 每个用户可以发表文章,但是没有自己独立的页面,可以称之为社区blog或是公用blog。这一类是目前blog程序的主流,将来也是。wordpress, s9y, 等等。

    4 纯粹的单用户blog,除blog主人之外其他用户只能发表评论。可以看作是对第3种的一种应用特例,说是第1种的一个用户。

    XOOPS目前没有完全意义上的多用户多blog(及第1种),有一些社区或公司开发/改进了自己的多用户多blog系统,比如集成lifetype,改动wp,但是依然没有稳定可靠的多用户版。单用户或是社区blog主要有集成的wordpress (XPress),完全基于XOOPS架构的weblog,其他还有几种。

    对XOOPS blog系统来说,我比较看重的是s9y的集成和wordpress for XOOPS多用户版(XPress-mu,不是那个鸡肋般的wp-mu)的实现。
    希望不久就会发布。