Is there any good cache for PHP?
Like I want to cache index.php homepage, 10 minutes Update once, how to write cache Ah!
Used to do. NET, now to PHP, many pages need to cache, do not know how to write PHP
It's better to have a demo.
such as index.php, and then others visit the time every 10 minutes Update 1 times index.html, of course index.html is index.php cache,
Do not generate index.html in time,
Requires index.php to update 1 data every 5 minutes
How to write Ah!!!
Build the best!!
------Solution--------------------
With Smarty template Wow, there is a cache, http://www.smarty.net/docsv2/en/, manual content seems a bit more, Google.
------Solution--------------------
All in English
------Solution--------------------
Memcached
------Solution--------------------
What do you do in. NET, just what you do in PHP
It's just a different dialect.
------Solution--------------------
Reference:
memcached
Memcached Cache page? Did you throw the entire page into a value?
------Solution--------------------
In this scenario memcached caching is a 2 thing. Without mentioning the amount of traffic, you generate a good pure static page, each time you have to load PHP, read from the memcached server, and then return to the client, the efficiency is very low.
The recommended method is to generate the index.html file cache, and then run the script to update periodically.
------Solution--------------------
You want to cache first to know why you want to cache, what you want to cache ...
Every answer upstairs is to some extent feasible, the key to see what you want to do ...
------Solution--------------------
To cache the entire page, you can create a static file on your own. Ob_start (), ob_get_contents (), flush (), or Ob_flush (), these four functions are sufficient.
Each time you request this page to determine if the static file exists, or the current time-its creation time >=10 minutes, the method is used to generate static pages. Otherwise, read the static file directly back to the browser.
------Solution--------------------
Memcached or Redis is suitable for caching data, which requires caching the entire page, preferably using the method above.
------Solution--------------------
Couch db
------Solution--------------------
Thank you for your help, I tested 1 page cache, generated 1 HTML, the key is not what I need,
For example, according to the conditions I query data, cache time set 1 minutes,
As a result, I chose the query condition, the data has not changed
What I want is to select the query time, data changes, colleagues, the same query conditions, 1 minutes to update,
For example, I choose the time zone and start by default is nearly 1 days of data,
When I choose the day before the condition of the query, want is the day before yesterday's verse,
If I query the day before the data, or the day before the data, but there will be no updates in 1 minutes, 1 minutes after the query will be updated,
In 1 minutes when I choose the data that is acquired, it is the acquired data, not the data of the day before
is the query conditions change, according to the conditions of the day 1 minutes or 1 hours, 1 days of cache,
does not affect other conditional queries, of course other conditions are 1 minutes or 1 hours. 1-Day Time cache
------Solution--------------------
In plain terms, the data is cached based on the conditional query.
------Solution--------------------
According to your #11 description, your vision is problematic.
In this case, you need to cache the scene from all the moments of history. Because anyone can start querying at any time in the past
A one-minute, one-year period, at least 6,151,680 cache items required
This is obviously not advisable.
Because the available query expressions are limited, you can create several views from a query expression. So that the query operation is done with the database background
------Solution--------------------
Oh, yes! So headache Ah!!!
So I want to put it in memory and clean up the memory regularly.
------Solution--------------------
File cache with input and output buffers
------Solution--------------------
Novice, passing ~ You this demand I think it's better to use a static page cache
------Solution--------------------
This is the same as some of the Web site navigation class website home cache. But they can cache the home page for a longer period of time, such as 1 months, 3 months ...
The specific methods are:
1, the home page refers to the relevant components (pictures, CSS files, JS files, etc.) into a special directory, such as the cache;
2. Add rules in htaccess:
#缓存首页物件
#RewriteCond%{http_host} ^www.162100.com [NC]
#RewriteCond%{request_uri} ^$ [OR]
#RewriteCond%{request_uri} ^/$ [OR]
#RewriteCond%{request_uri} ^/index.html$ [NC]
#RewriteRule (index\.html) gzip.php?cfile=$1 [L]
#RewriteRule ^ (cache\/.+) $ gzip.php?cfile=$1 [L]
3, the root directory (that is, a directory with index.html) to do a file gzip.php, the code is: