My favorites
▼
|
Sign in
p2-php-framework
This is an MVC framework and library on PHP.
Project Home
Wiki
Source
Checkout
|
Browse
|
Changes
|
‹r178
r192
Source path:
svn
/
trunk
/
Cache.php
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
<?php
/**
* P2_Cache
*
* (experimental)
*
* require
* * (none)
*
* @version 2.2.0
* @see http://code.google.com/p/p2-php-framework/
* @license The MIT license (http://www.opensource.org/licenses/mit-license.php)
*/
class P2_Cache {
static private $_dirPath;
private $_path;
private $_hasCache;
public static function setDir($dirPath = '/tmp') {
self::$_dirPath = $dirPath;
}
public function __construct($key, $duration = 3600) {
$this->_path = self::$_dirPath . '/' . $key;
$this->_hasCache = (
is_file($this->_path) &&
filemtime($this->_path) + $duration > time()
);
}
/**
* @return boolean LøÈLbV ðo͵½©Ç¤©
*/
public function start() {
if ($this->_hasCache) {
echo file_get_contents($this->_path);
return true;
} else {
ob_start();
return false;
}
}
public function end() {
file_put_contents($this->_path, ob_get_flush());
}
public function clear() {
unlink($this->_path);
}
public function hasCache() {
return $this->_hasCache;
}
}
Show details
Hide details
Change log
r191
by andozz on Mar 01, 2010
Diff
[No log message]
Go to:
/trunk/Cache.php
/trunk/Controller.php
/trunk/Data.php
/trunk/Db.php
/trunk/FileSystem.php
/trunk/Form.php
/trunk/Image.php
/trunk/Service/Rakuten.php
/trunk/Service/Twitter.php
/trunk/globalFunctions.php
Project members,
sign in
to write a code review
Older revisions
r178
by andozz on Dec 08, 2009
Diff
[No log message]
r175
by andozz on Nov 25, 2009
Diff
[No log message]
r172
by andozz on Nov 24, 2009
Diff
[No log message]
All revisions of this file
File info
Size: 1105 bytes, 55 lines
View raw file
Powered by
Google Project Hosting