CentOS installation memcached1. See if there is a version of memcached.[[emailprotected] bin]# yum list memcachedloaded plugins:securitybase | 3.7 KB 00:00 Epel |
One: memcached installation1) Install the extension source:Yum install-y Epel -release2) Install the relevant components:Yum install-y libevent memcached libmemcached3) Start the mamcached service:/etc/ init.d/memcached StartTo see if the startup was successful:PS aux |grep memcached650) this.width=650; "Src=" http://s1.51cto.com/wyfs02/M00/7E/5D/ Wkiom1b9fkcb
Memcached memory allocation mechanism and memcached Allocation Mechanism
In C, when malloc is used to allocate memory, memory fragments are generated, that is, idle and fragmented space cannot be used.
The Slab Allocator mechanism in Memcached relieves this problem.
Basic Principles:
According to the pre-defined size, the memory is divided into several sl
, obtain the saved data. The key "tokyo" to be obtained is also passed to the function library. The function library uses the same algorithm as the data storage algorithm to select a server based on the "key. If the algorithm used is the same, you can select the same server as the storage server and then send the get command. As long as the data is not deleted for some reason, you can get the saved value.
In this way, memcached is distributed by stor
49, Nginx Anti-theft chain, nginx access control, Nginx parsing PHP-related configuration, nginx agentFirst, nginx anti-theft chainMust be combined with "do not log and expire" because they are used at the same time.# vim/usr/local/nginx
data at the memcached server");echo "Store data in the cache (data would expire in seconds) $get _result = $mem->get (' TestKey ');echo "$get _result is from memcached server.";?>If there is an output of "Hello world was from memcached." And so on, it indicates that Memcache has been able to work properly.Iv. client-side tools using libmemcached:The traditional
We're off duty today. How to install, start, and uninstall memcached in the Windows operating system:1, download the relevant software::http://download.csdn.net/download/wangshuxuncom/8249501;2, extract the compressed files obtained, you will get a folder called "Memcached-1.2.6-win32-bin", the folder will be copied to the appropriate location (such as copy to the C packing directory);3, through the cmd com
APC and memcached, and then the read-write speed is tested.
Results on native windows:
Init=====0.0341ms
Apc_read=====0.0439ms
Apc_write=====0.0920ms
Mem_c
Mem_read=====0.2630ms
Mem_write=====0.2270ms
Results on Linux on the server:
Init=====0.0131ms
Apc_read=====0.0520ms
Apc_write=====0.0489ms
Mem_c
Mem_read=====0.1030ms
Mem_write=====0.0801ms
Of course, the repeated refresh will have different values, here just take a more average value.
Win under
to change the default port number. If you want to close the window and the memcache process is still running, add-d to the command to start it as a daemon.
7. Common MemCached commands can be viewed through [root @ SecurityCheck bin] #./memcached-h. Below are some common commands.
-D: Start a daemon process,-M: The amount of memory allocated to Memcache. The unit is MB. The default value is 64 MB,-U: the u
memcached-2.1.0.tgz
Cd memcached-2.1.0
/Usr/local/php/bin/phpize
. /Configure-enable-memcached-with-php-config =/usr/local/php/bin/php-config-with-zlib-dir-with-libmemcached-dir =/usr /local/libmemcached-prefix =/usr/local/phpmemcached
Make make install
Error: memcache support requires ZLIB solution
Yum install zlib-devel
Record the prompt after successful
Respect knowledge, reprinted please indicate this article from: programming artist poechant csdn blog http://blog.csdn.net/poechant
"Back-end server development series-" Practical memcached memory cache system "series blog: http://blog.csdn.net/poechant/article/category/1060687
Memcached is rarely used in real-time read/write scenarios. However, after memcached
Get started with memcached and memcached
Resource http://pan.baidu.com/s/1jHTRiU6 used in this article
You can view the usage documents at cainiao School (also included)
Http://www.runoob.com/memcached/window-install-memcached.html
Download and decompress the corresponding version of your system, and name the installation and startup.
Enable the telnet client
First, Memcached storage SessionBecause Memcached is a distributed memory object caching system, it can be used to implement Session synchronization: Combine the memory in the WEB server into a "memory pool", regardless of which server generates Sessoin can be put into this "memory pool", the other web Servers are available. The advantage of using Memcached to sy
go wrong during access. After defining the log, you cannot find anything in the log. It is preliminarily determined that it is related to the previous libevent update. Because the online server is used, you can use the script to make up for it.
#!/bin/sh pid=`ps aux|grep -v grep|grep memcached|awk '{print $2}'` memcached=`/usr/local/memcached/bin/
One: Nginx anti-theft chainAdd the following code in the server section of nginx.confLocation ~ ^.+. ( Gif|jpg|png|swf|flv|rar|zip|doc|pdf|gz|bz2|jpeg|bmp|xls) $ {Valid_referers None blocked Server_names taobao.com . baidu.com. google.com. cn . soso.com; The sites for these domain names are not hotlinking.if ($invalid _referer) {#return 403;Rewrite ^/http://www.example.com/nophoto.gif;}}Note: If location is already added to the previous configuration.
Usage conditions: when we do not have the permission or cannot use the server, we need to use socket to operate memcached.
Memcached-client operation
Features:
No need to enable memcache Extension
Connect to memcached using fsocketopen () socket
Execute crud
Require_once (class_path. 'memcached-client. PHP '); // clas
Memcached client summary, memcached Summary
This article will briefly introduce the features of memcached from the perspective of memcached usage, from the client, protocol, and server.
Memcached is a high-performance distributed K-V memory storage system, which maintains a
PHP module memcached User Guide, memcached User Guide. PHP module memcached User Guide, memcached User Guide 1. add the extension package php_memcache.dll2. add extensionphp_memcache.dll3 in PHP. the code for program copying is as follows: php creates the PHP module memcached
Linux memcached status QueryHow to view the memcached server-side version:./memcached-hThe running state of the memcached can be conveniently displayed with the stats command.First, use the Telnet 127.0.0.1 11211 command to connect to the Memcache, and then enter stats directly to get the status of the current memcache
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.