Tag:php redis cache
<?php/** based on the REDIS JS, CSS Cache class (effectively solve the TP and other framework access to public problems) *written by radish 2015.8.16*/define (' redis_host ', ' 127.0.0.1 ');d efine (' Redis_port ', 6379);//class im{function __construct () {$this->redis = new REDIS (); $this Redis->connect (Redis_host,redis_port);} Public function init ($array =[]) {if ($this->redis->get (' updated ') ==1) Return;foreach ($array as $k = = $v) {if ($v [0]== ' JS ') $this->redis->set ($k, ' <script> '. file_get_contents ($v [1]). ' </script> '), if ($v [0]== ' CSS ') $this->redis->set ($k, ' <style> '. file_get_contents ($v [1]). ' </style> ');} $this->redis->set (' updated ', 1);} Public function Get ($content = ') {echo $this->redis->get (' jquery ');}} $setup =[' jquery ' =>[' js ', ' http://lib.sinaapp.com/js/jquery/1.9.1/jquery-1.9.1.min.js ', ' Amazeui ' =>[' CSS ', ' Http://cdn.amazeui.org/amazeui/2.4.2/css/amazeui.css ', ' angular ' =>[' js ', ' http://lib.sinaapp.com/js/ Angular.js/angular-1.2.19/angular-animate.min.js ']; $k =new im (); $k->init ($setup); $k->get (' jquery ');
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
"PHP" is a Redis-based JS, CSS Cache class