12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- <?php
- namespace app\common\repositories\system;
- use app\common\dao\system\CacheDao;
- use app\common\repositories\BaseRepository;
- use think\db\exception\DbException;
- class CacheRepository extends BaseRepository
- {
-
- public function __construct(CacheDao $dao)
- {
- $this->dao = $dao;
- }
-
- public function save(string $key, $result, int $expire_time = 0)
- {
- if (!$this->dao->fieldExists('key', $key)) {
- $this->dao->create(compact('key', 'result', 'expire_time'));
- } else {
- $this->dao->keyUpdate($key, compact('result', 'expire_time'));
- }
- }
- }
|