深入eAccelerator与memcached的区别详解
eAccelerator和memcached,是目前较为主流的两个可使用在PHP之中的缓存加速工具.
eAccelerator专门为PHP开发,而memcached不仅仅用在PHP之中,其他所有的语言都可以使用.
eAccelerator的主要功能:
1. 缓存PHP文件的执行代码:在被缓存的代码再次被调用时,将直接从内存读取,从而在很大程度了PHP运行的速度.
2. 提供了共享内存操作函数:用户可以将自己的常见非资源对像,保存到内存之中,并可以随时读取出来.
memcached的主要功能:
提供共享内存操作函数,可以保存和读取数据
两者的共同点:
共同点:都提供了共享内存操作函数,可以用来保存和读取自己的数据
两者的区别:
eAccelerator作为PHP的扩展库存在,那么仅在PHP运行时,可以操作和读写共享内存,一般情况,只能由操作共享内存的程序自己调用.
同时,eAccelerator可以缓存PHP程序的执行代码,提升程序的调入和执行速度.
memcached主要作为一个共享内存服务器,其PHP扩展库仅仅作为PHP到memcached的连接库存在,类似MySQL扩展库.因而,memcached可以完全脱离PHP,其共享的数据,可以被不同的程序调用.
根据两者的不同,我们将他们使用在真真需要的地方:
eAccelerator主要用于单机PHP提速,缓存中间数据.对于实时性高,但数据操作量小的情况下,非常实用.
memcached用于分布式或者集群系统,多台服务器可以共享数据.对于实时性高,同时数据操作量大的情况下,非常实用.
对MemCached的正确认识
刚开始,听说用MemCached来缓存数据到内存,然后对数据进行操作,(这里的操作包括了,查询和更新),听起来真是太棒了。这样,一定时间内不用操作数据库。真是太好了。
然后我一直在想一个问题,查询确实可以,可是更新内存要怎么处理并发?难道,我们的MemCached 来有这般功能,如果这样,那真是太神了。
可是事情,并不是像说的那样。对MemCached的这样认识是不正确的。
MemCache和其他的cache是一样的,当数据更新之后,cached 的东西,也就是 out date 的东西了。
在网上看了,前辈们对MemCached的阐述,更是说明了这点。
所以,不应该指望,直接更新MemCached,而省略了数据库这一环节。
这前认为 他提供的set方法是用来更新数据库的,那时自己的痴心妄想。
其实这个方法是将数据库中的记录缓存到MemCached中,同时指定它的有效期是多长。
现在我想到了,为什么,我们的MemCached中的内容一直都没变化,即使我已经删除了该条记录。
我们在set()的时候,并没有设置它的过期时间,也就默认是0,即永不过期。只要MemCached服务器没有重起,它就一直存在。
这样说来,我们的ROR项目中,使用缓存来减少数据库的检索,而不能指望让MemCached可以让我们连更新数据库也免了。
如果真的连更新数据库也免了,就真的跨入了非数据库时代,哈哈。估计不太可能。如果我们能保证用户是以队列的方式 ,一个接着一个来的话。
还是另想办法来减轻更新带来的压力。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











Export password-protected PDF in Photoshop: Open the image file. Click "File"> "Export"> "Export as PDF". Set the "Security" option and enter the same password twice. Click "Export" to generate a PDF file.

The key differences between CentOS and Ubuntu are: origin (CentOS originates from Red Hat, for enterprises; Ubuntu originates from Debian, for individuals), package management (CentOS uses yum, focusing on stability; Ubuntu uses apt, for high update frequency), support cycle (CentOS provides 10 years of support, Ubuntu provides 5 years of LTS support), community support (CentOS focuses on stability, Ubuntu provides a wide range of tutorials and documents), uses (CentOS is biased towards servers, Ubuntu is suitable for servers and desktops), other differences include installation simplicity (CentOS is thin)

H5. The main difference between mini programs and APP is: technical architecture: H5 is based on web technology, and mini programs and APP are independent applications. Experience and functions: H5 is light and easy to use, with limited functions; mini programs are lightweight and have good interactiveness; APPs are powerful and have smooth experience. Compatibility: H5 is cross-platform compatible, applets and APPs are restricted by the platform. Development cost: H5 has low development cost, medium mini programs, and highest APP. Applicable scenarios: H5 is suitable for information display, applets are suitable for lightweight applications, and APPs are suitable for complex functions.

The necessity of registering VueRouter in the index.js file under the router folder When developing Vue applications, you often encounter problems with routing configuration. Special...

Detailed explanation of XPath search method under DOM nodes In JavaScript, we often need to find specific nodes from the DOM tree based on XPath expressions. If you need to...

不同数据库系统添加列的语法为:MySQL:ALTER TABLE table_name ADD column_name data_type;PostgreSQL:ALTER TABLE table_name ADD COLUMN column_name data_type;Oracle:ALTER TABLE table_name ADD (column_name data_type);SQL Server:ALTER TABLE table_name ADD column_name data_

Laravel and ThinkPHP are both popular PHP frameworks and have their own advantages and disadvantages in development. This article will compare the two in depth, highlighting their architecture, features, and performance differences to help developers make informed choices based on their specific project needs.

The state of the CentOS firewall can be viewed through the sudo firewall-cmd --state command, returning to running or not running. For more detailed information, you can use sudo firewall-cmd --list-all to view, including configured areas, services, ports, etc. If firewall-cmd does not solve the problem, you can use sudo iptables -L -n to view iptables rules. Be sure to make a backup before modifying the firewall configuration to ensure server security.
