Regarding the use of memcache (entry-level question), memcache has been configured. how can we use it to speed up access? For example, I have read a lot of materials online. most of them are about memcache configuration installation. & nbsp; and the function list is now configured. & nbsp; using echo for memcache usage (entry-level question), memcache has been configured. how can we use it to speed up access?
Example
I read a lot of information online, mostly about memcache configuration installation and function list.
Now echo $ memcache-> getVersion (); can be configured to print the published version.
How to perform further operations to increase the response speed
For example, I already know that a complicated SQL statement has been executed for a long time.
How to operate on this SQL statement?
If the description is not clear enough, please let me describe it as much as possible...
Thank you ~~ Memchache shared to: getVersion (); you can also print the published version, such as... 'data-pics = ''>
------ Solution --------------------
I guess you are wrong about the application scenario...
SQL statements are optimized first.
Of course, you can consider putting the table into the temporary memory table for processing.
------ Solution --------------------
Reference:
Example
I read a lot of information online, mostly about memcache configuration installation and function list.
Now echo $ memcache-> getVersion (); can be configured to print the published version.
How to perform further operations to increase the response speed
For example, I already know that a complicated SQL statement has been executed for a long time.
How to operate on this SQL statement?
If the description is not clear enough, please let me describe it as much as possible...
Thank you ~~
Memcache can share the pressure on mysql.
For example, if you have a select read statement to be executed, read from the memcache Cache before each database read, read from mysql if it cannot be read, and write the content to the cache for the next read from the cache.
Memcache can reduce the read pressure on the database service, and it is a cache. the read speed is fast and the load is low.
"For example, I already know that a complicated SQL statement has been executed for a long time." to make it faster, you can only optimize SQL statements.
If this sentence is a read operation, you can write the cache, and it will be very fast to read later.
Note that the cache must be updated during database update and delete operations .~~~
------ Solution --------------------
Memcache cannot relieve database pressure
If you plan to put the query results in memcache for the next use, will the data you get next time be old?
If you want to check whether the data in the database is updated, what does the cache do?
So what scenarios are memcache suitable?
When your program is already using files or databases to cache intermediate results, using memcache can improve the cache performance.
------ Solution --------------------
Cache is mainly used for pages or programs that do not update during a certain period of time and often connect to the database, such as weather forecasts and daily promotion pages of the mall. These accesses will be large and will not be updated for a long time, for example, you can update the data at 8 o'clock every day or divide it into several time periods to view your needs.
------ Solution --------------------
In your statement, memcache is not used to optimize SQL statements,
It is used to temporarily store the data obtained after accessing the database. after obtaining the data for the first time, it is stored. you do not need to query the database the next time you access the database. Instead, you can directly retrieve the data from the memory, this reduces the database access pressure.
Memcache is equivalent to an object-oriented access interface (a memory-cached procedural program)
Such logic in code
If ($ mem-> get ('key') {// determines whether the object has been stored
// Stored and retrieved from memory
} Else {
$ Mem-> set ('key', 'value') // no cache saved