wallet tron transactions
This commit is contained in:
59
app/Cache/Base/SetBaseCache.php
Normal file
59
app/Cache/Base/SetBaseCache.php
Normal file
@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
namespace App\Cache\Base;
|
||||
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Illuminate\Support\Facades\Redis;
|
||||
|
||||
//无序集合缓存基类
|
||||
abstract class SetBaseCache
|
||||
{
|
||||
|
||||
protected $client;
|
||||
protected string $prefix = 'Set:'; //缓存前缀
|
||||
protected string $set_name = ''; //集合名
|
||||
const CACHE_TTL = 60 * 60 * 24 * 3; //缓存时间 3天
|
||||
|
||||
function getRedis()
|
||||
{
|
||||
if(!$this->client) $this->client = Redis::client();
|
||||
return $this->client ;
|
||||
}
|
||||
|
||||
function getAll(): bool
|
||||
{
|
||||
return $this->getRedis()->sMembers($this->getSetName());
|
||||
}
|
||||
|
||||
function checkKey($value): bool
|
||||
{
|
||||
return $this->getRedis()->sIsMember($this->getSetName(),$value);
|
||||
}
|
||||
|
||||
function setKey($value): bool
|
||||
{
|
||||
return $this->getRedis()->sAdd($this->getSetName(),$value);
|
||||
}
|
||||
|
||||
function removeKey($value): bool
|
||||
{
|
||||
return $this->getRedis()->sRem($this->getSetName(),$value);
|
||||
}
|
||||
|
||||
function getCount()
|
||||
{
|
||||
return $this->getRedis()->sCard($this->getSetName());
|
||||
}
|
||||
|
||||
function getPrefix(): string
|
||||
{
|
||||
return $this->prefix;
|
||||
}
|
||||
|
||||
function getSetName(): string
|
||||
{
|
||||
return $this->getPrefix().$this->set_name;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user