PluginProbe
User Access Manager / 2.0.0
User Access Manager v2.0.0
2.3.20 2.3.19 2.3.18 2.3.17 2.3.16 2.3.15 2.3.14 2.3.13 trunk 0.6 0.6.1 0.6.2 0.7 0.7 Beta 0.7.0.1 0.8 0.8.0.1 0.8.0.2 0.9 0.9.1 0.9.1.1 0.9.1.2 0.9.1.3 0.9.1.4 1.0 All 136 releases
user-access-manager / src / UserAccessManager / Cache / Cache.php

Cache.php in User Access Manager 2.0.0, at src/UserAccessManager/Cache/Cache.php

76 lines 1.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Cache.php
4 *
5 * The Cache class file.
6 *
7 * PHP versions 5
8 *
9 * @author Alexander Schneider <alexanderschneider85@gmail.com>
10 * @copyright 2008-2017 Alexander Schneider
11 * @license http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License, version 2
12 * @version SVN: $id$
13 * @link http://wordpress.org/extend/plugins/user-access-manager/
14 */
15 namespace UserAccessManager\Cache;
16
17 /**
18 * Class Cache
19 *
20 * @package UserAccessManager\Cache
21 */
22 class Cache
23 {
24 /**
25 * @var array
26 */
27 private $cache = [];
28
29 /**
30 * Returns a generated cache key.
31 *
32 * @return string
33 */
34 public function generateCacheKey()
35 {
36 $arguments = func_get_args();
37
38 return implode('|', $arguments);
39 }
40
41 /**
42 * Adds the variable to the cache.
43 *
44 * @param string $key The cache key
45 * @param mixed $value The value.
46 */
47 public function addToCache($key, $value)
48 {
49 $this->cache[$key] = $value;
50 }
51
52 /**
53 * Returns a value from the cache by the given key.
54 *
55 * @param string $key
56 *
57 * @return mixed
58 */
59 public function getFromCache($key)
60 {
61 if (isset($this->cache[$key]) === true) {
62 return $this->cache[$key];
63 }
64
65 return null;
66 }
67
68 /**
69 * Flushes the cache.
70 */
71 public function flushCache()
72 {
73 $this->cache = [];
74 }
75 }
76