forked from dingproject/trampoline
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtrampoline.cache.inc
42 lines (37 loc) · 1.01 KB
/
trampoline.cache.inc
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
<?php
/**
* Default implementation of a static value caching.
*/
/**
* Gets a value from the cache.
*
* Uses same arguments as original cache_get.
*
* @see cache_get
*/
function cache_get($cid, $table = 'cache') {
global $trampoline_cache;
//Use a simple variable based cache.
//Cache will automatically expire after request completion
if (is_array($trampoline_cache) && array_key_exists($table . '_' . $cid, $trampoline_cache) && $trampoline_cache[$table.'_'.$cid]) {
return array('data' => $trampoline_cache[$table.'_'.$cid]);
} else {
return FALSE;
}
}
/**
* Caches a value.
*
* Uses same arguments as original cache_set.
*
* @see cache_set
*/
function cache_set($cid, $data, $table = 'cache', $expire = CACHE_PERMANENT, $headers = NULL) {
global $trampoline_cache;
//Use a simple variable based cache.
//Cache will automatically expire after request completion
if (!isset($trampoline_cache)) {
$trampoline_cache = array();
}
$trampoline_cache[$table.'_'.$cid] = $data;
}