头部banner
Signed-off-by:沈海生 <haisheng.shen@yoho.cn>
Showing
1 changed file
with
47 additions
and
18 deletions
@@ -68,7 +68,7 @@ class CacheRedis extends Root implements CacheInterface | @@ -68,7 +68,7 @@ class CacheRedis extends Root implements CacheInterface | ||
68 | * @return Redis | 68 | * @return Redis |
69 | * @throws DebugException | 69 | * @throws DebugException |
70 | */ | 70 | */ |
71 | - private function init() | 71 | + final private function init() |
72 | { | 72 | { |
73 | if (isset($this->redisInstances[$this->persistentID])) { | 73 | if (isset($this->redisInstances[$this->persistentID])) { |
74 | $redis = $this->redisInstances[$this->persistentID]; | 74 | $redis = $this->redisInstances[$this->persistentID]; |
@@ -164,8 +164,8 @@ class CacheRedis extends Root implements CacheInterface | @@ -164,8 +164,8 @@ class CacheRedis extends Root implements CacheInterface | ||
164 | 164 | ||
165 | /** | 165 | /** |
166 | * 设置key-value并设置过期时间 | 166 | * 设置key-value并设置过期时间 |
167 | - * @param $key | ||
168 | - * @param $val | 167 | + * @param string $key |
168 | + * @param string $val | ||
169 | * @param int $timeout 过期时间,单位:秒 | 169 | * @param int $timeout 过期时间,单位:秒 |
170 | * @return bool | 170 | * @return bool |
171 | * @throws DebugException | 171 | * @throws DebugException |
@@ -190,24 +190,24 @@ class CacheRedis extends Root implements CacheInterface | @@ -190,24 +190,24 @@ class CacheRedis extends Root implements CacheInterface | ||
190 | 190 | ||
191 | /** | 191 | /** |
192 | * 增量 | 192 | * 增量 |
193 | - * @param $key | ||
194 | - * @param int $value | 193 | + * @param string $key |
194 | + * @param string $value | ||
195 | * @throws DebugException | 195 | * @throws DebugException |
196 | */ | 196 | */ |
197 | public function increment($key, $value = 1) | 197 | public function increment($key, $value = 1) |
198 | { | 198 | { |
199 | - $this->init()->incrBy((string)$key, (int)$value); | 199 | + return $this->init()->incrBy((string)$key, (int)$value); |
200 | } | 200 | } |
201 | 201 | ||
202 | /** | 202 | /** |
203 | * 减量 | 203 | * 减量 |
204 | - * @param $key | 204 | + * @param string $key |
205 | * @param int $value | 205 | * @param int $value |
206 | * @throws DebugException | 206 | * @throws DebugException |
207 | */ | 207 | */ |
208 | public function decrement($key, $value = 1) | 208 | public function decrement($key, $value = 1) |
209 | { | 209 | { |
210 | - $this->init()->decrBy((string)$key, (int)$value); | 210 | + return $this->init()->decrBy((string)$key, (int)$value); |
211 | } | 211 | } |
212 | 212 | ||
213 | 213 | ||
@@ -237,45 +237,74 @@ class CacheRedis extends Root implements CacheInterface | @@ -237,45 +237,74 @@ class CacheRedis extends Root implements CacheInterface | ||
237 | 237 | ||
238 | /** | 238 | /** |
239 | * 向list左压入 | 239 | * 向list左压入 |
240 | - * @param $key | ||
241 | - * @param $value | 240 | + * @param string $key |
241 | + * @param string $value | ||
242 | * @throws DebugException | 242 | * @throws DebugException |
243 | */ | 243 | */ |
244 | public function lpush($key, $value) | 244 | public function lpush($key, $value) |
245 | { | 245 | { |
246 | - $this->init()->lPush((string)$key, $value); | 246 | + return $this->init()->lPush((string)$key, $value); |
247 | } | 247 | } |
248 | 248 | ||
249 | /** | 249 | /** |
250 | * 从list左弹出 | 250 | * 从list左弹出 |
251 | - * @param $key | 251 | + * @param string $key |
252 | * @throws DebugException | 252 | * @throws DebugException |
253 | */ | 253 | */ |
254 | public function lpop($key) | 254 | public function lpop($key) |
255 | { | 255 | { |
256 | - $this->init()->lPop((string)$key); | 256 | + return $this->init()->lPop((string)$key); |
257 | } | 257 | } |
258 | 258 | ||
259 | 259 | ||
260 | /** | 260 | /** |
261 | * 向list右压入 | 261 | * 向list右压入 |
262 | - * @param $key | ||
263 | - * @param $value | 262 | + * @param string $key |
263 | + * @param string $value | ||
264 | * @throws DebugException | 264 | * @throws DebugException |
265 | */ | 265 | */ |
266 | public function rpush($key, $value) | 266 | public function rpush($key, $value) |
267 | { | 267 | { |
268 | - $this->init()->rPush((string)$key); | 268 | + return $this->init()->rPush((string)$key, $value); |
269 | } | 269 | } |
270 | 270 | ||
271 | /** | 271 | /** |
272 | * 从list右弹出 | 272 | * 从list右弹出 |
273 | - * @param $key | 273 | + * @param string $key |
274 | * @throws DebugException | 274 | * @throws DebugException |
275 | */ | 275 | */ |
276 | public function rpop($key) | 276 | public function rpop($key) |
277 | { | 277 | { |
278 | - $this->init()->rPop((string)$key); | 278 | + return $this->init()->rPop((string)$key); |
279 | + } | ||
280 | + | ||
281 | + | ||
282 | + /** | ||
283 | + * 检查一个key是否存在 | ||
284 | + * @param string $key | ||
285 | + * @return int | ||
286 | + */ | ||
287 | + public function exists($key) | ||
288 | + { | ||
289 | + return $this->init()->exists((string)$key); | ||
290 | + } | ||
291 | + | ||
292 | + /** | ||
293 | + * 设置过期时间 | ||
294 | + * @param string $key | ||
295 | + * @param int $second | ||
296 | + * @return int | ||
297 | + */ | ||
298 | + public function expire($key, $second) | ||
299 | + { | ||
300 | + return $this->init()->expire((string)$key, (int)$second); | ||
301 | + } | ||
302 | + | ||
303 | + | ||
304 | + | ||
305 | + public function mget() | ||
306 | + { | ||
307 | + return $this->init()->mget(); | ||
279 | } | 308 | } |
280 | 309 | ||
281 | } | 310 | } |
-
Please register or login to post a comment