Use memcached in Apache for session Storage

Source: Internet
Author: User
Session. save_handlermemcachesession.save_pathtcp: 127.0.0.1: 11211 use commas (,) to separate multiple memcachedservers and use them as described in Memcache: addServer, it can contain additional persistent, weight, timeout, retry_interval, etc.

Session. save_handler = meMcAche
Session. save_path = "tCp: // 127.0.0.1: 11211"

Use multiple memcachEdSeparate the server with commas (,) and use Memcache:.DdServer (), which includes additional parameters such as "persistent", "weight", and ","TimeOut "," reTrY_interval "and so on, like this:" tcp: // host1: port1? Persistent = 1 & weight = 2, tcp: // host2: port2 ".

PhpSession_start (); $ _ SESSION ["UserID"] = 123; echo session _Id();?>
Use sessionid to query in memcached:

DuMp ($ memcache-> get ('19216821213cxycedec65b0883238c278eeb573e077 ');?>

When memcache is used to store sessionsFileS is much faster, and it is more convenient for multiple servers to share sessions. You can configure these servers to use the same group of memcached servers, reducing the additional workload. The disadvantage is that session data is stored in memory, which lacks persistence, but it is not a big problem for session data.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.