|
| 1 | +<?php |
| 2 | + |
| 3 | +/* |
| 4 | + * This file is part of the overtrue/laravel-wechat. |
| 5 | + * |
| 6 | + * (c) overtrue <[email protected]> |
| 7 | + * |
| 8 | + * This source file is subject to the MIT license that is bundled |
| 9 | + * with this source code in the file LICENSE. |
| 10 | + */ |
| 11 | + |
| 12 | +namespace Overtrue\LaravelWeChat; |
| 13 | + |
| 14 | +use Illuminate\Cache\Repository; |
| 15 | +use Psr\SimpleCache\CacheInterface; |
| 16 | + |
| 17 | +class CacheBridge implements CacheInterface |
| 18 | +{ |
| 19 | + /** |
| 20 | + * @var \Illuminate\Cache\Repository |
| 21 | + */ |
| 22 | + protected $repository; |
| 23 | + |
| 24 | + /** |
| 25 | + * @param \Illuminate\Cache\Repository $repository |
| 26 | + */ |
| 27 | + public function __construct(Repository $repository) |
| 28 | + { |
| 29 | + $this->repository = $repository; |
| 30 | + } |
| 31 | + |
| 32 | + public function get($key, $default = null) |
| 33 | + { |
| 34 | + return $this->repository->get($key, $default); |
| 35 | + } |
| 36 | + |
| 37 | + public function set($key, $value, $ttl = null) |
| 38 | + { |
| 39 | + return $this->repository->put($key, $value, $this->toMinutes($ttl)); |
| 40 | + } |
| 41 | + |
| 42 | + public function delete($key) |
| 43 | + { |
| 44 | + } |
| 45 | + |
| 46 | + public function clear() |
| 47 | + { |
| 48 | + } |
| 49 | + |
| 50 | + public function getMultiple($keys, $default = null) |
| 51 | + { |
| 52 | + } |
| 53 | + |
| 54 | + public function setMultiple($values, $ttl = null) |
| 55 | + { |
| 56 | + } |
| 57 | + |
| 58 | + public function deleteMultiple($keys) |
| 59 | + { |
| 60 | + } |
| 61 | + |
| 62 | + public function has($key) |
| 63 | + { |
| 64 | + return $this->repository->has($key); |
| 65 | + } |
| 66 | + |
| 67 | + protected function toMinutes($ttl = null) |
| 68 | + { |
| 69 | + if (!is_null($ttl)) { |
| 70 | + return $ttl / 60; |
| 71 | + } |
| 72 | + } |
| 73 | +} |
0 commit comments