Merge remote-tracking branch 'upstream/4.4' into 4.4-master-2014-08-19-00-06-22
[civicrm-core.git] / CRM / Utils / Cache / ArrayCache.php
CommitLineData
6a488035 1<?php
5bc392e6
EM
2
3/**
4 * Class CRM_Utils_Cache_Arraycache
5 */
6a488035
TO
6class 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 *
77b97be7 16 * @param array $config an array of configuration params
6a488035 17 *
77b97be7 18 * @return \CRM_Utils_Cache_Arraycache
6a488035
TO
19 */
20 function __construct($config) {
21 $this->_cache = array();
22 }
23
5bc392e6
EM
24 /**
25 * @param string $key
26 * @param mixed $value
27 */
6a488035
TO
28 function set($key, &$value) {
29 $this->_cache[$key] = $value;
30 }
31
5bc392e6
EM
32 /**
33 * @param string $key
34 *
35 * @return mixed
36 */
6a488035
TO
37 function get($key) {
38 return CRM_Utils_Array::value($key, $this->_cache);
39 }
40
5bc392e6
EM
41 /**
42 * @param string $key
43 */
6a488035
TO
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