Core technology:
Caching technology, Scheduled tasks
1 static Cache,
2.Memcache Redis Cache
Use caching to reduce server pressure
Static caching of static files saved on disk
PHP operation cache: Generate cache, get cache, delete cache;
<?php
class File () {
private $_dir;
Const EXT = ". txt";
Public function __construct () {
$this->_dir=dirname (__file__). " /files/";
}
/**
* Output communication data in an integrated manner
* @param string $key file name
* @param string $value data
* @param string $path path
* @return String
*/
Public function CacheData ($key, $value = ', $path = ') {
$filename = $this->_dir. $path. $key. Self::ext;
if ($value!== "") {
if (Is_null ($value)) {
return @unlink ($filename);
}
//write value value to cache
$dir =dirname ($filename);
if (!is_dir ($dir)) {
mkdir ($dir, 0777);
}
return file_put_contents ($filename, Json_encode ($value));
}
if (!is_file ($filename)) {
return false;
}else{
return Json_decode (file_get_contents ($filename), true);
}
}
}
?>
============================================================================
<?php
/* Above function, $value is empty is to get the cache, not empty is to write,
Null is to delete cache */
$file = new file ();
if ($file->cachedata (' Index_mk_cache ', null)) {
echo "Success";
}else{
echo "Error";
}
?>
PHP Development App Interface (iv)