forked from cynial/STBlog
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAutoClean.php
More file actions
72 lines (62 loc) · 1.57 KB
/
AutoClean.php
File metadata and controls
72 lines (62 loc) · 1.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<?php if (!defined('BASEPATH')) exit('No direct access allowed.');
/**
* STBlog Blogging System
*
* 基于Codeigniter的单用户多权限开源博客系统
*
* STBlog is an open source multi-privilege blogging System built on the
* well-known PHP framework Codeigniter.
*
* @package STBLOG
* @author Saturn <huyanggang@gmail.com>
* @copyright Copyright (c) 2009 - 2010, cnsaturn.com.
* @license GNU General Public License 2.0
* @link http://code.google.com/p/stblog/
* @version 0.1.0
*/
// ------------------------------------------------------------------------
/**
* STBLOG Page Cache Auto Clean Hook Class
*
* stblog自动清除页面缓存Hook
*
* @package STBLOG
* @subpackage Hooks
* @category Hooks
* @author Saturn <huyanggang@gmail.com>
* @link http://code.google.com/p/stblog/
*/
class AutoClean
{
/**
* CI句柄
*
* @access private
* @var object
*/
private $_CI;
private $_cache_file_limit;
public function __construct()
{
$this->_CI = & get_instance();
$limit = setting_item('cache_file_limit');
$this->_cache_file_limit = ($limit && is_numeric($limit)) ? intval($limit) : 200;
}
/**
* 根据文件缓存文件个数自动清除整页缓存
*
* @access public
* @return void
*/
public function clean_cache()
{
$path = $this->_CI->config->item('cache_path');
$filecount = count(glob($path . '*'));
if($filecount > $this->_cache_file_limit)
{
$this->_CI->utility->clear_file_cache();
}
}
}
/* End of file AutoClean.php */
/* Location: ./application/hooks/AutoClean.php */