


In-depth explanation of the difference between 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. Use .
The main functions of eAccelerator:
1. Cache the execution code of the PHP file: when the cached code is called again, it will be read directly from the memory Therefore, the speed of PHP running is greatly improved.
2. Provides shared memory operation functions: users can save their common non-resource objects into memory and read them out at any time.
The main functions of memcached:
Provides shared memory operation functions to save and read data
What the two have in common:
What they have in common: 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 only operate and read and write shared memory when PHP is running. In general, it can only be operated by the shared memory. The program calls itself.
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.
According to the difference 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, and 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 things are the out date things.
After reading it online, the explanations of MemCached by seniors further illustrate this point.
So, you should not expect to directly update MemCached and omit the database link.
I thought that the set method he provided was used to update the database. It was my wishful thinking at that time.
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 caching to reduce database retrieval, and 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.
Let’s 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

C language functions are the basis for code modularization and program building. They consist of declarations (function headers) and definitions (function bodies). C language uses values to pass parameters by default, but external variables can also be modified using address pass. Functions can have or have no return value, and the return value type must be consistent with the declaration. Function naming should be clear and easy to understand, using camel or underscore nomenclature. Follow the single responsibility principle and keep the function simplicity to improve maintainability and readability.

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.

C language functions are reusable code blocks. They receive input, perform operations, and return results, which modularly improves reusability and reduces complexity. The internal mechanism of the function includes parameter passing, function execution, and return values. The entire process involves optimization such as function inline. A good function is written following the principle of single responsibility, small number of parameters, naming specifications, and error handling. Pointers combined with functions can achieve more powerful functions, such as modifying external variable values. Function pointers pass functions as parameters or store addresses, and are used to implement dynamic calls to functions. Understanding function features and techniques is the key to writing efficient, maintainable, and easy to understand C programs.

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

Although C and C# have similarities, they are completely different: C is a process-oriented, manual memory management, and platform-dependent language used for system programming; C# is an object-oriented, garbage collection, and platform-independent language used for desktop, web application and game development.

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

There are differences in the promotion methods of H5 and mini programs: platform dependence: H5 depends on the browser, and mini programs rely on specific platforms (such as WeChat). User experience: The H5 experience is poor, and the mini program provides a smooth experience similar to native applications. Communication method: H5 is spread through links, and mini programs are shared or searched through the platform. H5 promotion methods: social sharing, email marketing, QR code, SEO, paid advertising. Mini program promotion methods: platform promotion, social sharing, offline promotion, ASO, cooperation with other platforms.
