"PHP" is a Redis-based JS, CSS Cache class

Source: Internet
Author: User

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

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.