Merge pull request #4789 from totten/master-test-tx
[civicrm-core.git] / CRM / Utils / Cache / ArrayCache.php
1 <?php
2
3 /**
4 * Class CRM_Utils_Cache_Arraycache
5 */
6 class CRM_Utils_Cache_Arraycache implements CRM_Utils_Cache_Interface {
7
8 /**
9 * The cache storage container, an in memory array by default
10 */
11 private $_cache;
12
13 /**
14 * Constructor
15 *
16 * @param array $config an array of configuration params
17 *
18 * @return \CRM_Utils_Cache_Arraycache
19 */
20 function __construct($config) {
21 $this->_cache = array();
22 }
23
24 /**
25 * @param string $key
26 * @param mixed $value
27 */
28 function set($key, &$value) {
29 $this->_cache[$key] = $value;
30 }
31
32 /**
33 * @param string $key
34 *
35 * @return mixed
36 */
37 function get($key) {
38 return CRM_Utils_Array::value($key, $this->_cache);
39 }
40
41 /**
42 * @param string $key
43 */
44 function delete($key) {
45 unset($this->_cache[$key]);
46 }
47
48 function flush() {
49 unset($this->_cache);
50 $this->_cache = array();
51 }
52 }
53