-
Notifications
You must be signed in to change notification settings - Fork 0
/
Caching.php
54 lines (43 loc) · 1.43 KB
/
Caching.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
<?php
require_once './config.php';
require_once './Predis/Autoloader.php';
Predis\Autoloader::register();
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/**
* Description of Caching
*
* @author trankimhieu
*/
class Caching {
//put your code here
public static function write($prefix = "tgm-mgod", $key = '', $value = '') {
$client = new Predis\Client(Config::$redis_server, array('prefix' => $prefix));
return $client->set($key, $value);
}
public static function read($prefix = "tgm-mgod", $key) {
$client = new Predis\Client(Config::$redis_server);
return $client->get(Config::$redis_prefix . $key);
}
public static function delete($prefix = "tgm-mgod", $key) {
$client = new Predis\Client(Config::$redis_server);
try {
return $client->del(Caching:: getListMatch(Config::$redis_prefix.$key));
} catch (Exception $e) {
}
}
public static function checkexist($prefix = "tgm-mgod", $key) {
$client = new Predis\Client(Config::$redis_server);
if ($client->exists(Config::$redis_prefix . $key))
return true;
else
return false;
}
public static function getListMatch($param) {
$client = new Predis\Client(Config::$redis_server);
return $client->keys($param);
}
}
?>