| @@ 223-232 (lines=10) @@ | ||
| 220 | * @override |
|
| 221 | * @inheritDoc |
|
| 222 | */ |
|
| 223 | public function getTtl($key) |
|
| 224 | { |
|
| 225 | if (!$this->isStarted()) |
|
| 226 | { |
|
| 227 | return Promise::doReject(new ReadException('Cache object is not open.')); |
|
| 228 | } |
|
| 229 | return $this->redis->ttl($key)->then(function($result) { |
|
| 230 | return $result > 0 ? $result : 0; |
|
| 231 | }); |
|
| 232 | } |
|
| 233 | ||
| 234 | /** |
|
| 235 | * @override |
|
| @@ 238-247 (lines=10) @@ | ||
| 235 | * @override |
|
| 236 | * @inheritDoc |
|
| 237 | */ |
|
| 238 | public function removeTtl($key) |
|
| 239 | { |
|
| 240 | if (!$this->isStarted()) |
|
| 241 | { |
|
| 242 | return Promise::doReject(new WriteException('Cache object is not open.')); |
|
| 243 | } |
|
| 244 | return $this->redis->persist($key)->then(function($result) { |
|
| 245 | return $result > 0; |
|
| 246 | }); |
|
| 247 | } |
|
| 248 | ||
| 249 | /** |
|
| 250 | * @override |
|
| @@ 253-262 (lines=10) @@ | ||
| 250 | * @override |
|
| 251 | * @inheritDoc |
|
| 252 | */ |
|
| 253 | public function existsTtl($key) |
|
| 254 | { |
|
| 255 | if (!$this->isStarted()) |
|
| 256 | { |
|
| 257 | return Promise::doReject(new ReadException('Cache object is not open.')); |
|
| 258 | } |
|
| 259 | return $this->redis->ttl($key)->then(function($result) { |
|
| 260 | return $result >= 0; |
|
| 261 | }); |
|
| 262 | } |
|
| 263 | ||
| 264 | /** |
|
| 265 | * @override |
|
| @@ 268-278 (lines=11) @@ | ||
| 265 | * @override |
|
| 266 | * @inheritDoc |
|
| 267 | */ |
|
| 268 | public function getKeys() |
|
| 269 | { |
|
| 270 | if (!$this->isStarted()) |
|
| 271 | { |
|
| 272 | return Promise::doReject(new ReadException('Cache object is not open.')); |
|
| 273 | } |
|
| 274 | return $this->redis->keys()->then(function($result) { |
|
| 275 | sort($result); |
|
| 276 | return $result; |
|
| 277 | }); |
|
| 278 | } |
|
| 279 | ||
| 280 | /** |
|
| 281 | * @override |
|