格式化代码;新增全局数据存储工具;

This commit is contained in:
2024-02-22 22:30:39 +08:00
parent f4c1fc9210
commit 667608d233
5 changed files with 80 additions and 19 deletions

View File

@@ -0,0 +1,33 @@
<?php
namespace base\common\tools;
use think\helper\Arr;
/**
* 全局数据存储工具.
*
* 可以在当前生命周期内,存储一些全局数据,
* 相比SESSION性能更高但是只能在当前生命周期内使用常驻内存服务时除外
*/
class StoreValueToolsBase
{
protected static $store = [];
public static function set($key, $value)
{
return Arr::set(static::$store, $key, $value);
}
public static function get($key, $default = null)
{
return Arr::get(static::$store, $key, $default);
}
public static function __callStatic($name, $arguments)
{
$arguments = array_merge([static::$store], $arguments);
return call_user_func_array([Arr::class, $name], $arguments);
}
}