1 | <?php |
||
22 | class RedisAdapter |
||
23 | { |
||
24 | const KEY_SHA_VARS = 'sha_vars'; |
||
25 | const KEY_SHA_VAR = 'sha_var'; |
||
26 | |||
27 | const KEY_HASH_PREFIXES = 'hash_prefixes'; |
||
28 | const KEY_HASH_PREFIX = 'hash_prefix'; |
||
29 | |||
30 | const KEY_CHUNK_NUMS = 'chunk_nums'; |
||
31 | const KEY_CHUNK_NUM = 'chunk_num'; |
||
32 | |||
33 | /** |
||
34 | * @var Client |
||
35 | */ |
||
36 | private $client; |
||
37 | |||
38 | public function __construct($dsn = '', $options = []) |
||
42 | |||
43 | /** |
||
44 | * @param string $dsn |
||
45 | * @param array $options |
||
46 | * @param bool $reset |
||
47 | * @return Client |
||
48 | */ |
||
49 | public function initClient($dsn = '', $options = [], $reset = false) |
||
58 | |||
59 | /** |
||
60 | * @param string $shaVar |
||
61 | */ |
||
62 | public function addShaVar($shaVar) |
||
66 | |||
67 | /** |
||
68 | * @param string $shaVar |
||
69 | * @param string $chunkNum |
||
70 | */ |
||
71 | public function addChunkNum($shaVar, $chunkNum) |
||
75 | |||
76 | /** |
||
77 | * @param string $shaVar |
||
78 | * @param string $chunkNum |
||
79 | * @param string $hashPrefix |
||
80 | */ |
||
81 | public function addHashPrefix($shaVar, $chunkNum, $hashPrefix) |
||
89 | |||
90 | /** |
||
91 | * @param string $shaVar |
||
92 | * @param string $chunkNum |
||
93 | * @param string $hashPrefix |
||
94 | */ |
||
95 | public function saveHashPrefix($shaVar, $chunkNum, $hashPrefix) |
||
101 | |||
102 | public function getShaVars() |
||
106 | |||
107 | /** |
||
108 | * @param string $shaVar |
||
109 | * @return array |
||
110 | */ |
||
111 | public function getChunkNums($shaVar) |
||
115 | |||
116 | /** |
||
117 | * @param string $shaVar |
||
118 | * @param string $chunkNum |
||
119 | * @return array |
||
120 | */ |
||
121 | public function getHashPrefixes($shaVar, $chunkNum) |
||
125 | |||
126 | /** |
||
127 | * @param string $hashPrefix |
||
128 | * @return string|null |
||
129 | */ |
||
130 | public function getHashPrefix($hashPrefix) |
||
134 | |||
135 | /** |
||
136 | * @param string $shaVar |
||
137 | * @param string $chunkNum |
||
138 | */ |
||
139 | public function removeChunkNum($shaVar, $chunkNum) |
||
145 | |||
146 | /** |
||
147 | * @param string $shaVar |
||
148 | * @param string $chunkNum |
||
149 | * @param string $hashPrefix |
||
150 | */ |
||
151 | public function removeHashPrefix($shaVar, $chunkNum, $hashPrefix) |
||
157 | |||
158 | /** |
||
159 | * @param array $hashes |
||
160 | * @return bool |
||
161 | */ |
||
162 | public function hasHashes($hashes) |
||
176 | } |
||
177 |
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: