1 |
85ad3d82
|
Assos Assos
|
<?php
|
2 |
|
|
|
3 |
|
|
/**
|
4 |
|
|
* @file
|
5 |
|
|
* A simple cache indirection mechanism that just uses the basic object cache.
|
6 |
|
|
*/
|
7 |
|
|
|
8 |
|
|
$plugin = array(
|
9 |
|
|
// cache plugins are the rare plugin types that have no real UI but
|
10 |
|
|
// we're providing a title just in case.
|
11 |
|
|
'title' => t('Simple'),
|
12 |
|
|
'cache get' => 'ctools_cache_simple_cache_get',
|
13 |
|
|
'cache set' => 'ctools_cache_simple_cache_set',
|
14 |
|
|
'cache clear' => 'ctools_cache_simple_cache_clear',
|
15 |
|
|
);
|
16 |
|
|
|
17 |
|
|
function ctools_cache_simple_cache_get($data, $key) {
|
18 |
|
|
ctools_include('object-cache');
|
19 |
|
|
|
20 |
|
|
// Ensure that if there is somehow no data, we at least don't stomp on other
|
21 |
|
|
// people's caches.
|
22 |
|
|
if (empty($data)) {
|
23 |
|
|
$data = 'simple_cache_plugin';
|
24 |
|
|
}
|
25 |
|
|
|
26 |
|
|
return ctools_object_cache_get($data, $key);
|
27 |
|
|
}
|
28 |
|
|
|
29 |
|
|
function ctools_cache_simple_cache_set($data, $key, $object) {
|
30 |
|
|
ctools_include('object-cache');
|
31 |
|
|
|
32 |
|
|
// Ensure that if there is somehow no data, we at least don't stomp on other
|
33 |
|
|
// people's caches.
|
34 |
|
|
if (empty($data)) {
|
35 |
|
|
$data = 'simple_cache_plugin';
|
36 |
|
|
}
|
37 |
|
|
|
38 |
|
|
return ctools_object_cache_set($data, $key, $object);
|
39 |
|
|
}
|
40 |
|
|
|
41 |
|
|
function ctools_cache_simple_cache_clear($data, $key) {
|
42 |
|
|
ctools_include('object-cache');
|
43 |
|
|
|
44 |
|
|
// Ensure that if there is somehow no data, we at least don't stomp on other
|
45 |
|
|
// people's caches.
|
46 |
|
|
if (empty($data)) {
|
47 |
|
|
$data = 'simple_cache_plugin';
|
48 |
|
|
}
|
49 |
|
|
|
50 |
|
|
return ctools_object_cache_clear($data, $key);
|
51 |
|
|
} |