wallet tron transactions
This commit is contained in:
42
app/Cache/Base/KeyBaseCache.php
Normal file
42
app/Cache/Base/KeyBaseCache.php
Normal file
@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace App\Cache\Base;
|
||||
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
|
||||
abstract class KeyBaseCache
|
||||
{
|
||||
protected string $prefix = 'Key:'; //缓存前缀
|
||||
const CACHE_TTL = 60 * 60 * 24 * 3; //缓存时间 3天
|
||||
|
||||
function getByKey($key): string|array|bool|null
|
||||
{
|
||||
return Cache::get($key);
|
||||
}
|
||||
|
||||
function setKey($key, $value): bool
|
||||
{
|
||||
return Cache::put($this->getKey($key), $value);
|
||||
}
|
||||
|
||||
function setKeyWithExp($key, $value, $exp = self::CACHE_TTL): bool
|
||||
{
|
||||
return Cache::put($this->getKey($key), $value, $exp);
|
||||
}
|
||||
|
||||
function getPrefix(): string
|
||||
{
|
||||
return $this->prefix;
|
||||
}
|
||||
|
||||
function getKey($key): string
|
||||
{
|
||||
return $this->getPrefix().$key;
|
||||
}
|
||||
|
||||
function removeKey($key): bool
|
||||
{
|
||||
return Cache::forget($this->getKey($key));
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user