Merge remote-tracking branch 'upstream/4.5' into 4.5-master-2015-02-25-11-27-40
[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 /**
fe482240 14 * Constructor.
6a488035 15 *
77855840
TO
16 * @param array $config
17 * An array of configuration params.
6a488035 18 *
77b97be7 19 * @return \CRM_Utils_Cache_Arraycache
6a488035 20 */
00be9182 21 public function __construct($config) {
6a488035
TO
22 $this->_cache = array();
23 }
24
5bc392e6
EM
25 /**
26 * @param string $key
27 * @param mixed $value
28 */
00be9182 29 public function set($key, &$value) {
6a488035
TO
30 $this->_cache[$key] = $value;
31 }
32
5bc392e6
EM
33 /**
34 * @param string $key
35 *
36 * @return mixed
37 */
00be9182 38 public function get($key) {
6a488035
TO
39 return CRM_Utils_Array::value($key, $this->_cache);
40 }
41
5bc392e6
EM
42 /**
43 * @param string $key
44 */
00be9182 45 public function delete($key) {
6a488035
TO
46 unset($this->_cache[$key]);
47 }
48
00be9182 49 public function flush() {
6a488035
TO
50 unset($this->_cache);
51 $this->_cache = array();
52 }
96025800 53
6a488035 54}