-
The plug-in generates the json data of the entire database article (and uses the hooks of typecho to ensure that the data is updated synchronously when publishing new articles and modifying articles). This data can be stored in two ways (file form, database) -
When the blog is opened, the json data will be loaded to the front end -
When searching, match the json data directly
-
In the process of requesting json data, the search function is unavailable -
Traffic problems caused by too large json data
if ($_SESSION['search_cache'] === false){ $object['status'] = false; //If the data is stored in the database, it will be read from the database. Here, it is read from the cache file $filePath = __TYPECHO_ROOT_DIR__ . __ TYPECHO_PLUGIN_DIR__ . DIRECTORY_SEPARATOR.'Handsome'.DIRECTORY_SEPARATOR.'cache'.DIRECTORY_SEPARATOR.'search.json'; $file = file_get_contents($filePath); if ($file === false){ $fail = "{}"; $_SESSION['search_cache'] = $fail; echo $fail; }else{ $_SESSION['search_cache'] = $file; } }else{ $object['status'] = true; } //Process search data and return results ...