JaguarJack 94c430f491 update
2020-11-29 09:29:14 +08:00

66 lines
1.5 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
declare(strict_types=1);
// +----------------------------------------------------------------------
// | CatchAdmin [Just Like ]
// +----------------------------------------------------------------------
// | Copyright (c) 2017~2020 http://catchadmin.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( https://github.com/yanwenwu/catch-admin/blob/master/LICENSE.txt )
// +----------------------------------------------------------------------
// | Author: JaguarJack [ njphper@gmail.com ]
// +----------------------------------------------------------------------
namespace catcher\library\rate;
use think\facade\Cache;
trait Redis
{
/**
* @var \Redis
*/
protected $redis = null;
/**
* 返回 redis
*
* @time 2020年07月02日
* @return \Redis
*/
protected function getRedis(): \Redis
{
if (!$this->redis) {
$this->redis = Cache::store('redis')->handler();
}
return $this->redis;
}
/**
* 设置 ttl
*
* @time 2020年06月30日
* @param $ttl
* @return $this
*/
public function ttl($ttl)
{
$this->ttl = $ttl;
return $this;
}
/**
* 设置限制次数
*
* @time 2020年06月30日
* @param $limit
* @return $this
*/
public function limit($limit)
{
$this->limit = $limit;
return $this;
}
}