PHP Cache technology Static cache Memcache Cache Redis Cache

Source: Internet
Author: User
Tags delete cache
PHP Operation Cache

Generated

Get

Delete

 1 class file{2 private $_dir; 3 const ext= '. txt '; 4 public Function __consruct () {5 $this->_dir dirname (__file___). ' Files/'; 6} 7 Public Function CacheData ($key, value= ", $path =") {8 $filename = $this->_dir. $path. $key. Self::ext;            9 if ($value!== ") {//write value to cache//delete cache if (Is_null ($value)) {return @unlike ($filename)            }10 $dir =dirname ($filename), one if (!is_dir ($dir)) {mkdir ($dir, 0777); 13}14                    Return file_put_contents ($filename, Jsonencode ($value)), if (!is_file ($filename)) {               return FALSE;                }else{return Json_decode (File_get_content ($filename), true); }16}24 25} 26 27 28//Generate Cache $file = new Firl (), if ($file->cachedata (' Index_mk_cache ', $data)) {EC Ho "Success";}else (echo "false"; 35) 36//Get Cache 
$file = new Firl (); if ($file->cachedata (' Index_mk_cache ')) {var_dump ($file->cahcedata (' Index_mk_cache ')); exit; echo "Success";} Else (echo "false";) Delete Cache
37
  • 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.