-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFCacheHelper.php
executable file
·45 lines (39 loc) · 1.01 KB
/
FCacheHelper.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
<?php
/**
* This file is part of the Marvarid project.
*
* (c) Fazliddin Jo'raev
*
* For the full copyright and license information, please view the LICENSE file
* that was distributed with this source code.
*/
class FCacheHelper
{
const AS_SECONDS = 1;
const AS_MINUTES = 60;
const AS_HOURS = 3600;
const AS_DAYS = 86400;
const AS_MONTH = 2592000;
public static function set($id, $data, $timeOut=0, $timeUnit = Utils::AS_HOURS)
{
if (($cache = Yii::app()->cache) !== null)
$cache->set($id, $data, $timeOut*$timeUnit);
}
public static function delete($id)
{
if (($cache = Yii::app()->cache) !== null)
$cache->delete($id);
}
public static function get($id)
{
if(($cache = Yii::app()->cache) !== null)
return $cache->get($id);
else
return false;
}
public static function flush()
{
if(($cache = Yii::app()->cache) !== null)
$cache->flush();
}
}