1 | <?php |
||
16 | class WidgetCache |
||
17 | { |
||
18 | /** |
||
19 | * @var Client |
||
20 | */ |
||
21 | private $redis; |
||
22 | /** |
||
23 | * @var AuthorizationChecker |
||
24 | */ |
||
25 | private $authorizationChecker; |
||
26 | /** |
||
27 | * @var WidgetHelper |
||
28 | */ |
||
29 | private $widgetHelper; |
||
30 | |||
31 | /** |
||
32 | * WidgetCache constructor. |
||
33 | * |
||
34 | * @param Client $redis |
||
35 | * @param AuthorizationChecker $authorizationChecker |
||
36 | * @param WidgetHelper $widgetHelper |
||
37 | */ |
||
38 | public function __construct(Client $redis, AuthorizationChecker $authorizationChecker, WidgetHelper $widgetHelper) |
||
44 | |||
45 | /** |
||
46 | * @param Widget $widget |
||
47 | * |
||
48 | * @return string |
||
49 | */ |
||
50 | public function fetch(Widget $widget) |
||
54 | |||
55 | /** |
||
56 | * @param Widget $widget |
||
57 | * |
||
58 | * @return int |
||
59 | */ |
||
60 | public function remove(Widget $widget) |
||
64 | |||
65 | /** |
||
66 | * @param Widget $widget |
||
67 | * @param $content |
||
68 | */ |
||
69 | public function save(Widget $widget, $content) |
||
77 | |||
78 | /** |
||
79 | * clear all redis cache. |
||
80 | */ |
||
81 | public function clear() |
||
85 | |||
86 | /** |
||
87 | * @param Widget $widget |
||
88 | * |
||
89 | * @return string |
||
90 | */ |
||
91 | protected function getHash(Widget $widget) |
||
106 | |||
107 | protected function generateBusinessEntityHash(Widget $widget) |
||
116 | |||
117 | private function generateHash(Widget $widget) |
||
124 | } |
||
125 |
In PHP, under loose comparison (like
==
, or!=
, orswitch
conditions), values of different types might be equal.For
string
values, the empty string''
is a special case, in particular the following results might be unexpected: