diff --git a/server/.example.env b/server/.example.env index 8807f8e1c21f4934a32ca5101b3281f3e7c93df6..23c8380a9f97ca59a39afaaf36dbc25a5d9b6a01 100644 --- a/server/.example.env +++ b/server/.example.env @@ -1 +1,30 @@ -APP_DEBUG = true [APP] DEFAULT_TIMEZONE = Asia/Shanghai [DATABASE] TYPE = mysql HOSTNAME = 127.0.0.1 DATABASE = test USERNAME = username PASSWORD = password HOSTPORT = 3306 CHARSET = utf8mb4 DEBUG = true PREFIX = la_ [LANG] default_lang = zh-cn [PROJECT] UNIQUE_IDENTIFICATION = likeadmin # 演示环境 DEMO_ENV = false \ No newline at end of file +APP_DEBUG = true + +[APP] +DEFAULT_TIMEZONE = Asia/Shanghai + +[DATABASE] +TYPE = mysql +HOSTNAME = 127.0.0.1 +DATABASE = test +USERNAME = username +PASSWORD = password +HOSTPORT = 3306 +CHARSET = utf8mb4 +DEBUG = true +PREFIX = la_ + +[CACHE] +DRIVER = file +HOST = 127.0.0.1 +PORT = 6379 +PASSWORD = "" +PREFIX = "la" + +[LANG] +default_lang = zh-cn + +[PROJECT] +UNIQUE_IDENTIFICATION = likeadmin +# 演示环境 +DEMO_ENV = false \ No newline at end of file diff --git a/server/app/adminapi/logic/setting/system/CacheLogic.php b/server/app/adminapi/logic/setting/system/CacheLogic.php index 294fd15f715b77679fdacc25d32b7a604ab6c150..3adedd58853a76bb9085ad34c92cfe47bf138b8d 100644 --- a/server/app/adminapi/logic/setting/system/CacheLogic.php +++ b/server/app/adminapi/logic/setting/system/CacheLogic.php @@ -31,7 +31,13 @@ class CacheLogic extends BaseLogic */ public static function clear() { - Cache::clear(); - del_target_dir(app()->getRootPath().'runtime/file',true); + $redis = Cache::store()->handler(); + if ($redis !== null) { + $keys = $redis->keys(env('cache.prefix') . '*'); + foreach ($keys as $key => $value) { + $redis->del($value); + } + } + del_target_dir(app()->getRootPath() . 'runtime/file', true); } } \ No newline at end of file diff --git a/server/config/cache.php b/server/config/cache.php index ce0ff9f07b6d0fbbc91cd016fd94c44105669627..19e7ce905ef52023751e761215d5c51dd57a542e 100644 --- a/server/config/cache.php +++ b/server/config/cache.php @@ -16,7 +16,7 @@ return [ // 缓存保存目录 'path' => '', // 缓存前缀 - 'prefix' => 'la', + 'prefix' => env('cache.prefix', 'la'), // 缓存有效期 0表示永久缓存 'expire' => 0, // 缓存标签前缀 @@ -27,15 +27,15 @@ return [ // redis缓存 'redis' => [ // 驱动方式 - 'type' => 'redis', + 'type' => 'redis', // 服务器地址 - 'host' => env('cache.host','like-redis'), + 'host' => env('cache.host','like-redis'), // 端口 - 'port' => env('cache.port','6379'), + 'port' => env('cache.port','6379'), // 密码 - 'password' => env('cache.password', ''), + 'password' => env('cache.password', ''), // 缓存前缀 - 'prefix' => 'la:', + 'prefix' => env('cache.prefix', 'la') . ':', ], ], ];