PluginProbe
Independent Analytics – WordPress Analytics Plugin / 1.29.0
Independent Analytics – WordPress Analytics Plugin v1.29.0
2.15.5 2.15.4 2.15.3 2.15.2 2.15.1 2.15.0 2.14.10 trunk 1.1 1.10 1.10.1 1.11 1.12 1.13 1.14 1.15 1.16 1.17 1.17.1 1.17.2 1.17.3 1.17.4 1.18 1.18.1 1.19.0 All 120 releases
independent-analytics / vendor / matomo / device-detector / Cache / StaticCache.php
StaticCache.php
65 lines 1.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Device Detector - The Universal Device Detection library for parsing User Agents
5 *
6 * @link https://matomo.org
7 *
8 * @license http://www.gnu.org/licenses/lgpl.html LGPL v3 or later
9 */
10 declare (strict_types=1);
11 namespace IAWP_SCOPED\DeviceDetector\Cache;
12
13 /**
14 * Class StaticCache
15 *
16 * Simple Cache that caches in a static property
17 * (Speeds up multiple detections in one request)
18 */
19 class StaticCache implements CacheInterface
20 {
21 /**
22 * Holds the static cache data
23 * @var array
24 */
25 protected static $staticCache = [];
26 /**
27 * @inheritdoc
28 */
29 public function fetch(string $id)
30 {
31 return $this->contains($id) ? self::$staticCache[$id] : \false;
32 }
33 /**
34 * @inheritdoc
35 */
36 public function contains(string $id) : bool
37 {
38 return isset(self::$staticCache[$id]) || \array_key_exists($id, self::$staticCache);
39 }
40 /**
41 * @inheritdoc
42 */
43 public function save(string $id, $data, int $lifeTime = 0) : bool
44 {
45 self::$staticCache[$id] = $data;
46 return \true;
47 }
48 /**
49 * @inheritdoc
50 */
51 public function delete(string $id) : bool
52 {
53 unset(self::$staticCache[$id]);
54 return \true;
55 }
56 /**
57 * @inheritdoc
58 */
59 public function flushAll() : bool
60 {
61 self::$staticCache = [];
62 return \true;
63 }
64 }
65