How PHP is cached to memcache based on URL parameters

Source: Internet
Author: User
How does PHP cache to memcache based on URL parameters?
 
  $file =file (' link.txt ');
$max =count ($file)-1;
for ($i =0; $i <5; $i + +) {
$index =mt_rand (0, $max);
$temp = "". Trim ($file ["$index"]). "";

}
$link = Memcache_init ();
$minute _now = Date (' I ', Time ());//Take the current number of minutes
$key = ' rate '. $minute _now;
if (Memcache_get ($link, $key) = = null)
{
Memcache_set ($link, $key, $temp, 0,//set);
Note that 20 here is the cache expiration time, 60 seconds is 1 minutes

}
$re = Memcache_get ($link, $key, $temp);
Var_dump ($re);
if ($re >ratemax)
{

}else{
Memcache_increment ($link, $key);
}


?>

Each refresh is changed without a cache
After caching
Demo Address http://niaochen006.sinaapp.com/zq.php
Cache time 20 seconds change once

What I want to achieve is
Http://niaochen006.sinaapp.com/zq.php?=AABB
Http://niaochen006.sinaapp.com/zq.php?=BBCC
http://niaochen006.sinaapp.com/zq.php?=*****

Cache different pages for each URL parameter
How to achieve it?


------Solution--------------------
Transform $key
You're now.
$key = ' rate '. $minute _now;
It's associated with time.

Change it to $url related.
  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.