


The difference and uses of eAccelerator and memcached_PHP tutorial
eAccelerator and memcached are currently two of the more mainstream caching acceleration tools that can be used in PHP.
eAccelerator is specially developed for PHP, while memcached is not only used in PHP, but can be used in all other languages.
Main functions of eAccelerator:
1. Cache the execution code of PHP files: When the cached code is called again, it will be read directly from the memory, thereby greatly reducing the speed of PHP running.
2. Provides shared memory operation functions: users can save their common non-resource objects into memory and read them out at any time.
Main functions of memcached:
Provides shared memory operation functions to save and read data
What the two have in common:
Common ground: both provide shared memory operation functions, which can be used to save and read your own data
The difference between the two:
eAccelerator exists as an extension library of PHP, so it can operate, read and write shared memory only when PHP is running. In general, it can only be called by the program itself that operates the shared memory.
At the same time, eAccelerator can cache the execution code of PHP programs to improve the loading and execution speed of the program.
memcached is mainly used as a shared memory server, and its PHP extension library only exists as a connection library from PHP to memcached, similar to the MySQL extension library. Therefore, memcached can be completely separated from PHP, and its shared data can be called by different programs.
Based on the differences between the two, we use them where they are really needed:
eAccelerator is mainly used to speed up stand-alone PHP and cache intermediate data. It is very practical when real-time performance is high but the amount of data operations is small.
Memcached is used in distributed or cluster systems. Multiple servers can share data. It is very practical when real-time performance is high and the amount of data operations is large.
Correct understanding of MemCached
At first, I heard that MemCached is used to cache data into memory and then operate on the data (the operations here include query and update), which sounds really great. In this way, there is no need to operate the database for a certain period of time. It's so good.
Then I have been thinking about a question. Querying is indeed possible, but how to handle concurrency when updating memory? Could it be that our MemCached has such a function? If so, that would be amazing.
But things are not as they say. This understanding of MemCached is incorrect.
MemCache is the same as other caches. When the data is updated, the cached items are the out date items.
After reading on the Internet, the explanations of MemCached by seniors illustrate this point.
Therefore, you should not expect to directly update MemCached and omit the database link.
I used to think that the set method he provided was used to update the database. At that time, I was just wishful thinking.
In fact, this method is to cache the records in the database into MemCached and specify its validity period.
Now I think about why, the content in our MemCached has not changed, even if I have deleted the record.
When we set(), we did not set its expiration time, so the default is 0, which means it will never expire. As long as the MemCached server is not restarted, it will always exist.
In this way, in our ROR project, we use cache to reduce database retrieval, but we cannot expect that MemCached will save us from updating the database.
If you really don’t even need to update the database, you will really have entered the non-database era, haha. Probably unlikely. If we can ensure that users come in a queue, one after another.
It’s better to find another way to reduce the pressure caused by updates.

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.

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.

Linux is widely used in servers, embedded systems and desktop environments. 1) In the server field, Linux has become an ideal choice for hosting websites, databases and applications due to its stability and security. 2) In embedded systems, Linux is popular for its high customization and efficiency. 3) In the desktop environment, Linux provides a variety of desktop environments to meet the needs of different users.

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...

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)

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.
