提交 c1e8003c 编写于 作者: G gongfuxiang

缓存key统一读取

上级 d87a143d
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
namespace app\admin\controller; namespace app\admin\controller;
use app\service\SystemService;
use app\service\ApiService; use app\service\ApiService;
use app\service\PluginsService; use app\service\PluginsService;
use app\service\ResourcesService; use app\service\ResourcesService;
...@@ -85,7 +86,7 @@ class Plugins extends Common ...@@ -85,7 +86,7 @@ class Plugins extends Common
} }
// 插件权限校验 // 插件权限校验
$power_plugins = MyCache(MyConfig('shopxo.cache_admin_power_plugins_key').$this->admin['id']); $power_plugins = MyCache(SystemService::CacheKey('shopxo.cache_admin_power_plugins_key').$this->admin['id']);
if(empty($power_plugins) || !array_key_exists($params['data_request']['pluginsname'], $power_plugins)) if(empty($power_plugins) || !array_key_exists($params['data_request']['pluginsname'], $power_plugins))
{ {
$msg = '无权限使用该插件'; $msg = '无权限使用该插件';
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
namespace app\admin\controller; namespace app\admin\controller;
use app\service\SystemService;
use app\service\ConfigService; use app\service\ConfigService;
use app\service\GoodsService; use app\service\GoodsService;
use app\service\SiteService; use app\service\SiteService;
...@@ -382,11 +383,11 @@ class Site extends Common ...@@ -382,11 +383,11 @@ class Site extends Common
{ {
// 登录 // 登录
case 'login' : case 'login' :
MyCache(MyConfig('shopxo.cache_user_login_left_key'), null); MyCache(SystemService::CacheKey('shopxo.cache_user_login_left_key'), null);
// 密码找回 // 密码找回
case 'forgetpwd' : case 'forgetpwd' :
MyCache(MyConfig('shopxo.cache_user_forgetpwd_left_key'), null); MyCache(SystemService::CacheKey('shopxo.cache_user_forgetpwd_left_key'), null);
break; break;
} }
} }
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
namespace app\index\controller; namespace app\index\controller;
use app\service\SystemService;
use app\service\OrderService; use app\service\OrderService;
use app\service\GoodsService; use app\service\GoodsService;
use app\service\UserService; use app\service\UserService;
...@@ -221,7 +222,7 @@ class User extends Common ...@@ -221,7 +222,7 @@ class User extends Common
MyViewAssign('home_seo_site_title', SeoService::BrowserSeoTitle('密码找回', 1)); MyViewAssign('home_seo_site_title', SeoService::BrowserSeoTitle('密码找回', 1));
// 左侧图片,随机其中一个 // 左侧图片,随机其中一个
$left_data = UserService::UserEntranceLeftData(['left_key'=>'forgetpwd', 'cache_key'=>MyConfig('shopxo.cache_user_forgetpwd_left_key')]); $left_data = UserService::UserEntranceLeftData(['left_key'=>'forgetpwd', 'cache_key'=>SystemService::CacheKey('shopxo.cache_user_forgetpwd_left_key')]);
MyViewAssign('user_forgetpwd_left_data', empty($left_data['data']) ? [] : $left_data['data'][array_rand($left_data['data'], 1)]); MyViewAssign('user_forgetpwd_left_data', empty($left_data['data']) ? [] : $left_data['data'][array_rand($left_data['data'], 1)]);
return MyView(); return MyView();
...@@ -287,7 +288,7 @@ class User extends Common ...@@ -287,7 +288,7 @@ class User extends Common
MyViewAssign('referer_url', $this->GetrefererUrl()); MyViewAssign('referer_url', $this->GetrefererUrl());
// 左侧图片,随机其中一个 // 左侧图片,随机其中一个
$left_data = UserService::UserEntranceLeftData(['left_key'=>'login', 'cache_key'=>MyConfig('shopxo.cache_user_login_left_key')]); $left_data = UserService::UserEntranceLeftData(['left_key'=>'login', 'cache_key'=>SystemService::CacheKey('shopxo.cache_user_login_left_key')]);
MyViewAssign('user_login_left_data', empty($left_data['data']) ? [] : $left_data['data'][array_rand($left_data['data'], 1)]); MyViewAssign('user_login_left_data', empty($left_data['data']) ? [] : $left_data['data'][array_rand($left_data['data'], 1)]);
return MyView(); return MyView();
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
namespace app\service; namespace app\service;
use think\facade\Db; use think\facade\Db;
use app\service\SystemService;
use app\service\AdminService; use app\service\AdminService;
use app\service\AdminRoleService; use app\service\AdminRoleService;
...@@ -189,9 +190,9 @@ class AdminPowerService ...@@ -189,9 +190,9 @@ class AdminPowerService
{ {
foreach($admin as $id) foreach($admin as $id)
{ {
MyCache(MyConfig('shopxo.cache_admin_left_menu_key').$id, null); MyCache(SystemService::CacheKey('shopxo.cache_admin_left_menu_key').$id, null);
MyCache(MyConfig('shopxo.cache_admin_power_key').$id, null); MyCache(SystemService::CacheKey('shopxo.cache_admin_power_key').$id, null);
MyCache(MyConfig('shopxo.cache_admin_power_plugins_key').$id, null); MyCache(SystemService::CacheKey('shopxo.cache_admin_power_plugins_key').$id, null);
} }
} }
} }
...@@ -213,9 +214,9 @@ class AdminPowerService ...@@ -213,9 +214,9 @@ class AdminPowerService
$role_id = isset($admin['role_id']) ? intval($admin['role_id']) : 0; $role_id = isset($admin['role_id']) ? intval($admin['role_id']) : 0;
// 读取缓存数据 // 读取缓存数据
$admin_left_menu = MyCache(MyConfig('shopxo.cache_admin_left_menu_key').$admin_id); $admin_left_menu = MyCache(SystemService::CacheKey('shopxo.cache_admin_left_menu_key').$admin_id);
$admin_power = MyCache(MyConfig('shopxo.cache_admin_power_key').$admin_id); $admin_power = MyCache(SystemService::CacheKey('shopxo.cache_admin_power_key').$admin_id);
$admin_plugins = MyCache(MyConfig('shopxo.cache_admin_power_plugins_key').$admin_id); $admin_plugins = MyCache(SystemService::CacheKey('shopxo.cache_admin_power_plugins_key').$admin_id);
// 缓存没数据则从数据库重新读取 // 缓存没数据则从数据库重新读取
if((($role_id > 0 || $admin_id == 1) && empty($admin_left_menu)) || $is_refresh || MyEnv('app_debug')) if((($role_id > 0 || $admin_id == 1) && empty($admin_left_menu)) || $is_refresh || MyEnv('app_debug'))
...@@ -309,9 +310,9 @@ class AdminPowerService ...@@ -309,9 +310,9 @@ class AdminPowerService
$admin_plugins = Db::name('RolePlugins')->where(['role_id'=>$role_id])->column('name', 'plugins'); $admin_plugins = Db::name('RolePlugins')->where(['role_id'=>$role_id])->column('name', 'plugins');
} }
} }
MyCache(MyConfig('shopxo.cache_admin_left_menu_key').$admin_id, $admin_left_menu); MyCache(SystemService::CacheKey('shopxo.cache_admin_left_menu_key').$admin_id, $admin_left_menu);
MyCache(MyConfig('shopxo.cache_admin_power_key').$admin_id, $admin_power); MyCache(SystemService::CacheKey('shopxo.cache_admin_power_key').$admin_id, $admin_power);
MyCache(MyConfig('shopxo.cache_admin_power_plugins_key').$admin_id, $admin_plugins); MyCache(SystemService::CacheKey('shopxo.cache_admin_power_plugins_key').$admin_id, $admin_plugins);
} }
return true; return true;
} }
...@@ -329,7 +330,7 @@ class AdminPowerService ...@@ -329,7 +330,7 @@ class AdminPowerService
$admin = AdminService::LoginInfo(); $admin = AdminService::LoginInfo();
if(!empty($admin['id'])) if(!empty($admin['id']))
{ {
$data = MyCache(MyConfig('shopxo.cache_admin_left_menu_key').$admin['id']); $data = MyCache(SystemService::CacheKey('shopxo.cache_admin_left_menu_key').$admin['id']);
} }
// 后台左侧菜单钩子 // 后台左侧菜单钩子
...@@ -357,7 +358,7 @@ class AdminPowerService ...@@ -357,7 +358,7 @@ class AdminPowerService
$admin = AdminService::LoginInfo(); $admin = AdminService::LoginInfo();
if(!empty($admin['id'])) if(!empty($admin['id']))
{ {
$data = MyCache(MyConfig('shopxo.cache_admin_power_key').$admin['id']); $data = MyCache(SystemService::CacheKey('shopxo.cache_admin_power_key').$admin['id']);
} }
// 后台左侧菜单权限钩子 // 后台左侧菜单权限钩子
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
namespace app\service; namespace app\service;
use think\facade\Db; use think\facade\Db;
use app\service\SystemService;
use app\service\AdminPowerService; use app\service\AdminPowerService;
/** /**
...@@ -506,9 +507,9 @@ class AdminService ...@@ -506,9 +507,9 @@ class AdminService
if(Db::name('Admin')->where(['id'=>$admin['id']])->update($data)) if(Db::name('Admin')->where(['id'=>$admin['id']])->update($data))
{ {
// 清空权限缓存数据 // 清空权限缓存数据
MyCache(MyConfig('shopxo.cache_admin_left_menu_key').$admin['id'], null); MyCache(SystemService::CacheKey('shopxo.cache_admin_left_menu_key').$admin['id'], null);
MyCache(MyConfig('shopxo.cache_admin_power_key').$admin['id'], null); MyCache(SystemService::CacheKey('shopxo.cache_admin_power_key').$admin['id'], null);
MyCache(MyConfig('shopxo.cache_admin_power_plugins_key').$admin['id'], null); MyCache(SystemService::CacheKey('shopxo.cache_admin_power_plugins_key').$admin['id'], null);
// 权限菜单初始化 // 权限菜单初始化
AdminPowerService::PowerMenuInit(); AdminPowerService::PowerMenuInit();
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
namespace app\service; namespace app\service;
use think\facade\Db; use think\facade\Db;
use app\service\SystemService;
use app\service\ResourcesService; use app\service\ResourcesService;
/** /**
...@@ -274,7 +275,7 @@ class AppCenterNavService ...@@ -274,7 +275,7 @@ class AppCenterNavService
public static function AppCenterNav($params = []) public static function AppCenterNav($params = [])
{ {
// 缓存 // 缓存
$key = MyConfig('shopxo.cache_app_user_center_navigation_key').APPLICATION_CLIENT_TYPE; $key = SystemService::CacheKey('shopxo.cache_app_user_center_navigation_key').APPLICATION_CLIENT_TYPE;
$data = MyCache($key); $data = MyCache($key);
if(empty($data)) if(empty($data))
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
namespace app\service; namespace app\service;
use think\facade\Db; use think\facade\Db;
use app\service\SystemService;
use app\service\ResourcesService; use app\service\ResourcesService;
/** /**
...@@ -269,7 +270,7 @@ class AppHomeNavService ...@@ -269,7 +270,7 @@ class AppHomeNavService
public static function AppHomeNav($params = []) public static function AppHomeNav($params = [])
{ {
// 缓存 // 缓存
$key = MyConfig('shopxo.cache_app_home_navigation_key').APPLICATION_CLIENT_TYPE; $key = SystemService::CacheKey('shopxo.cache_app_home_navigation_key').APPLICATION_CLIENT_TYPE;
$data = MyCache($key); $data = MyCache($key);
if($data === null || MyEnv('app_debug')) if($data === null || MyEnv('app_debug'))
{ {
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
namespace app\service; namespace app\service;
use think\facade\Db; use think\facade\Db;
use app\service\SystemService;
use app\service\ResourcesService; use app\service\ResourcesService;
/** /**
...@@ -34,7 +35,7 @@ class ArticleService ...@@ -34,7 +35,7 @@ class ArticleService
public static function HomeArticleList($params = []) public static function HomeArticleList($params = [])
{ {
// 从缓存获取 // 从缓存获取
$key = MyConfig('shopxo.cache_home_article_list_key'); $key = SystemService::CacheKey('shopxo.cache_home_article_list_key');
$data = MyCache($key); $data = MyCache($key);
if($data === null || MyEnv('app_debug')) if($data === null || MyEnv('app_debug'))
{ {
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
namespace app\service; namespace app\service;
use think\facade\Db; use think\facade\Db;
use app\service\SystemService;
use app\service\ResourcesService; use app\service\ResourcesService;
/** /**
...@@ -34,7 +35,7 @@ class BannerService ...@@ -34,7 +35,7 @@ class BannerService
public static function Banner($params = []) public static function Banner($params = [])
{ {
// 缓存 // 缓存
$key = MyConfig('shopxo.cache_banner_list_key').APPLICATION_CLIENT_TYPE; $key = SystemService::CacheKey('shopxo.cache_banner_list_key').APPLICATION_CLIENT_TYPE;
$data = MyCache($key); $data = MyCache($key);
if($data === null || MyEnv('app_debug')) if($data === null || MyEnv('app_debug'))
{ {
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
namespace app\service; namespace app\service;
use think\facade\Db; use think\facade\Db;
use app\service\SystemService;
use app\service\ResourcesService; use app\service\ResourcesService;
/** /**
...@@ -204,7 +205,7 @@ class ConfigService ...@@ -204,7 +205,7 @@ class ConfigService
if($success > 0) if($success > 0)
{ {
// 删除所有配置的缓存数据 // 删除所有配置的缓存数据
MyCache(MyConfig('shopxo.cache_common_my_config_key'), null); MyCache(SystemService::CacheKey('shopxo.cache_common_my_config_key'), null);
// 所有配置信息更新 // 所有配置信息更新
self::ConfigInit(1); self::ConfigInit(1);
...@@ -257,7 +258,7 @@ class ConfigService ...@@ -257,7 +258,7 @@ class ConfigService
*/ */
public static function ConfigInit($status = 0) public static function ConfigInit($status = 0)
{ {
$key = MyConfig('shopxo.cache_common_my_config_key'); $key = SystemService::CacheKey('shopxo.cache_common_my_config_key');
$data = MyCache($key); $data = MyCache($key);
if($data === null || $status == 1) if($data === null || $status == 1)
{ {
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
namespace app\service; namespace app\service;
use think\facade\Db; use think\facade\Db;
use app\service\SystemService;
use app\service\SystemBaseService; use app\service\SystemBaseService;
use app\service\ResourcesService; use app\service\ResourcesService;
use app\service\BrandService; use app\service\BrandService;
...@@ -63,7 +64,7 @@ class GoodsService ...@@ -63,7 +64,7 @@ class GoodsService
public static function GoodsCategoryAll($params = []) public static function GoodsCategoryAll($params = [])
{ {
// 从缓存获取 // 从缓存获取
$key = MyConfig('shopxo.cache_goods_category_key'); $key = SystemService::CacheKey('shopxo.cache_goods_category_key');
$data = MyCache($key); $data = MyCache($key);
if($data === null || MyEnv('app_debug')) if($data === null || MyEnv('app_debug'))
{ {
...@@ -219,7 +220,7 @@ class GoodsService ...@@ -219,7 +220,7 @@ class GoodsService
public static function HomeFloorList($params = []) public static function HomeFloorList($params = [])
{ {
// 缓存 // 缓存
$key = MyConfig('shopxo.cache_goods_floor_list_key'); $key = SystemService::CacheKey('shopxo.cache_goods_floor_list_key');
$data = MyCache($key); $data = MyCache($key);
if($data === null || MyEnv('app_debug')) if($data === null || MyEnv('app_debug'))
{ {
...@@ -2639,7 +2640,7 @@ class GoodsService ...@@ -2639,7 +2640,7 @@ class GoodsService
} }
// 删除大分类缓存 // 删除大分类缓存
MyCache(MyConfig('shopxo.cache_goods_category_key'), null); MyCache(SystemService::CacheKey('shopxo.cache_goods_category_key'), null);
$res = self::GoodsCategoryDataHandle([$data]); $res = self::GoodsCategoryDataHandle([$data]);
return DataReturn('操作成功', 0, json_encode($res[0])); return DataReturn('操作成功', 0, json_encode($res[0]));
...@@ -2681,7 +2682,7 @@ class GoodsService ...@@ -2681,7 +2682,7 @@ class GoodsService
if(Db::name('GoodsCategory')->where(['id'=>$ids])->delete()) if(Db::name('GoodsCategory')->where(['id'=>$ids])->delete())
{ {
// 删除大分类缓存 // 删除大分类缓存
MyCache(MyConfig('shopxo.cache_goods_category_key'), null); MyCache(SystemService::CacheKey('shopxo.cache_goods_category_key'), null);
return DataReturn('删除成功', 0); return DataReturn('删除成功', 0);
} }
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
namespace app\service; namespace app\service;
use think\facade\Db; use think\facade\Db;
use app\service\SystemService;
use app\service\GoodsService; use app\service\GoodsService;
/** /**
...@@ -34,7 +35,7 @@ class LinkService ...@@ -34,7 +35,7 @@ class LinkService
public static function HomeLinkList($params = []) public static function HomeLinkList($params = [])
{ {
// 从缓存获取 // 从缓存获取
$key = MyConfig('shopxo.cache_home_link_list_key'); $key = SystemService::CacheKey('shopxo.cache_home_link_list_key');
$data = MyCache($key); $data = MyCache($key);
if($data == null || MyEnv('app_debug')) if($data == null || MyEnv('app_debug'))
{ {
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
namespace app\service; namespace app\service;
use think\facade\Db; use think\facade\Db;
use app\service\SystemService;
use app\service\BuyService; use app\service\BuyService;
use app\service\MessageService; use app\service\MessageService;
use app\service\OrderService; use app\service\OrderService;
...@@ -40,8 +41,8 @@ class NavigationService ...@@ -40,8 +41,8 @@ class NavigationService
public static function Nav($params = []) public static function Nav($params = [])
{ {
// 读取缓存数据 // 读取缓存数据
$header = MyCache(MyConfig('shopxo.cache_common_home_nav_header_key')); $header = MyCache(SystemService::CacheKey('shopxo.cache_common_home_nav_header_key'));
$footer = MyCache(MyConfig('shopxo.cache_common_home_nav_footer_key')); $footer = MyCache(SystemService::CacheKey('shopxo.cache_common_home_nav_footer_key'));
// 缓存没数据则从数据库重新读取,顶部菜单 // 缓存没数据则从数据库重新读取,顶部菜单
if($header === null || MyEnv('app_debug')) if($header === null || MyEnv('app_debug'))
...@@ -157,7 +158,7 @@ class NavigationService ...@@ -157,7 +158,7 @@ class NavigationService
} }
// 缓存 // 缓存
MyCache(MyConfig('shopxo.cache_common_home_nav_'.$nav_type.'_key'), $data, 180); MyCache(SystemService::CacheKey('shopxo.cache_common_home_nav_'.$nav_type.'_key'), $data, 180);
return $data; return $data;
} }
...@@ -470,7 +471,7 @@ class NavigationService ...@@ -470,7 +471,7 @@ class NavigationService
public static function NacDataSave($params = []) public static function NacDataSave($params = [])
{ {
// 缓存 key // 缓存 key
$cache_key = MyConfig('shopxo.cache_common_home_nav_'.$params['nav_type'].'_key'); $cache_key = SystemService::CacheKey('shopxo.cache_common_home_nav_'.$params['nav_type'].'_key');
// 非自定义导航数据处理 // 非自定义导航数据处理
if(empty($params['name'])) if(empty($params['name']))
...@@ -573,8 +574,8 @@ class NavigationService ...@@ -573,8 +574,8 @@ class NavigationService
Db::commit(); Db::commit();
// 清除缓存 // 清除缓存
MyCache(MyConfig('shopxo.cache_common_home_nav_header_key'), null); MyCache(SystemService::CacheKey('shopxo.cache_common_home_nav_header_key'), null);
MyCache(MyConfig('shopxo.cache_common_home_nav_footer_key'), null); MyCache(SystemService::CacheKey('shopxo.cache_common_home_nav_footer_key'), null);
return DataReturn('删除成功'); return DataReturn('删除成功');
} }
...@@ -623,8 +624,8 @@ class NavigationService ...@@ -623,8 +624,8 @@ class NavigationService
if(Db::name('Navigation')->where(['id'=>intval($params['id'])])->update([$params['field']=>intval($params['state']), 'upd_time'=>time()])) if(Db::name('Navigation')->where(['id'=>intval($params['id'])])->update([$params['field']=>intval($params['state']), 'upd_time'=>time()]))
{ {
// 清除缓存 // 清除缓存
MyCache(MyConfig('shopxo.cache_common_home_nav_header_key'), null); MyCache(SystemService::CacheKey('shopxo.cache_common_home_nav_header_key'), null);
MyCache(MyConfig('shopxo.cache_common_home_nav_footer_key'), null); MyCache(SystemService::CacheKey('shopxo.cache_common_home_nav_footer_key'), null);
return DataReturn('编辑成功'); return DataReturn('编辑成功');
} }
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
namespace app\service; namespace app\service;
use think\facade\Db; use think\facade\Db;
use app\service\SystemService;
use app\service\PluginsService; use app\service\PluginsService;
use app\service\ResourcesService; use app\service\ResourcesService;
use app\service\SqlConsoleService; use app\service\SqlConsoleService;
...@@ -64,7 +65,7 @@ class PluginsAdminService ...@@ -64,7 +65,7 @@ class PluginsAdminService
$admin = AdminService::LoginInfo(); $admin = AdminService::LoginInfo();
if(!empty($admin)) if(!empty($admin))
{ {
$res = MyCache(MyConfig('shopxo.cache_admin_power_plugins_key').$admin['id']); $res = MyCache(SystemService::CacheKey('shopxo.cache_admin_power_plugins_key').$admin['id']);
if(!empty($res)) if(!empty($res))
{ {
$power_plugins = $res; $power_plugins = $res;
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
namespace app\service; namespace app\service;
use think\facade\Db; use think\facade\Db;
use app\service\SystemService;
use app\service\ResourcesService; use app\service\ResourcesService;
use app\service\PluginsAdminService; use app\service\PluginsAdminService;
use app\service\StoreService; use app\service\StoreService;
...@@ -186,7 +187,7 @@ class PluginsService ...@@ -186,7 +187,7 @@ class PluginsService
*/ */
public static function PluginsCacheStorage($plugins, $data) public static function PluginsCacheStorage($plugins, $data)
{ {
return MyCache(MyConfig('shopxo.cache_plugins_data_key').$plugins, $data); return MyCache(SystemService::CacheKey('shopxo.cache_plugins_data_key').$plugins, $data);
} }
/** /**
...@@ -200,7 +201,7 @@ class PluginsService ...@@ -200,7 +201,7 @@ class PluginsService
*/ */
public static function PluginsCacheData($plugins) public static function PluginsCacheData($plugins)
{ {
return MyCache(MyConfig('shopxo.cache_plugins_data_key').$plugins); return MyCache(SystemService::CacheKey('shopxo.cache_plugins_data_key').$plugins);
} }
/** /**
...@@ -214,7 +215,7 @@ class PluginsService ...@@ -214,7 +215,7 @@ class PluginsService
*/ */
public static function PluginsCacheDelete($plugins) public static function PluginsCacheDelete($plugins)
{ {
MyCache(MyConfig('shopxo.cache_plugins_data_key').$plugins, null); MyCache(SystemService::CacheKey('shopxo.cache_plugins_data_key').$plugins, null);
} }
/** /**
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
namespace app\service; namespace app\service;
use think\facade\Db; use think\facade\Db;
use app\service\SystemService;
use app\service\ResourcesService; use app\service\ResourcesService;
/** /**
...@@ -268,7 +269,7 @@ class QuickNavService ...@@ -268,7 +269,7 @@ class QuickNavService
public static function QuickNav($params = []) public static function QuickNav($params = [])
{ {
// 缓存 // 缓存
$key = MyConfig('shopxo.cache_quick_navigation_key').APPLICATION_CLIENT_TYPE; $key = SystemService::CacheKey('shopxo.cache_quick_navigation_key').APPLICATION_CLIENT_TYPE;
$data = MyCache($key); $data = MyCache($key);
if($data === null || MyEnv('app_debug')) if($data === null || MyEnv('app_debug'))
{ {
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
namespace app\service; namespace app\service;
use think\facade\Db; use think\facade\Db;
use app\service\SystemService;
/** /**
* 地区服务层 * 地区服务层
...@@ -261,7 +262,7 @@ class RegionService ...@@ -261,7 +262,7 @@ class RegionService
public static function RegionAll($params = []) public static function RegionAll($params = [])
{ {
// 缓存 // 缓存
$key = MyConfig('shopxo.cache_region_all_key'); $key = SystemService::CacheKey('shopxo.cache_region_all_key');
$data = MyCache($key); $data = MyCache($key);
if(empty($data)) if(empty($data))
{ {
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
namespace app\service; namespace app\service;
use think\facade\Db; use think\facade\Db;
use app\service\SystemService;
use app\service\GoodsService; use app\service\GoodsService;
use app\service\BrandService; use app\service\BrandService;
use app\service\ResourcesService; use app\service\ResourcesService;
...@@ -380,7 +381,7 @@ class SearchService ...@@ -380,7 +381,7 @@ class SearchService
*/ */
public static function SearchKeywordsList($params = []) public static function SearchKeywordsList($params = [])
{ {
$key = MyConfig('shopxo.cache_search_keywords_key'); $key = SystemService::CacheKey('shopxo.cache_search_keywords_key');
$data = MyCache($key); $data = MyCache($key);
if($data === null || MyEnv('app_debug')) if($data === null || MyEnv('app_debug'))
{ {
......
...@@ -139,5 +139,19 @@ class SystemService ...@@ -139,5 +139,19 @@ class SystemService
return $value; return $value;
} }
/**
* 缓存key获取
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2022-04-21
* @desc description
* @param [string] $key [缓存key]
*/
public static function CacheKey($key)
{
return MyConfig($key).'_'.SYSTEM_TYPE;
}
} }
?> ?>
\ No newline at end of file
...@@ -95,7 +95,7 @@ class UserService ...@@ -95,7 +95,7 @@ class UserService
self::UserLoginRecord($user_login_info['id']); self::UserLoginRecord($user_login_info['id']);
if(!empty($user_login_info['token'])) if(!empty($user_login_info['token']))
{ {
MyCache(MyConfig('shopxo.cache_user_info').$user_login_info['token'], $user_login_info); MyCache(SystemService::CacheKey('shopxo.cache_user_info').$user_login_info['token'], $user_login_info);
} }
} }
} }
...@@ -114,7 +114,7 @@ class UserService ...@@ -114,7 +114,7 @@ class UserService
*/ */
public static function UserTokenData($token) public static function UserTokenData($token)
{ {
$user = MyCache(MyConfig('shopxo.cache_user_info').$token); $user = MyCache(SystemService::CacheKey('shopxo.cache_user_info').$token);
if($user !== null && isset($user['id'])) if($user !== null && isset($user['id']))
{ {
return $user; return $user;
...@@ -2107,7 +2107,7 @@ class UserService ...@@ -2107,7 +2107,7 @@ class UserService
$user['token'] = self::CreatedUserToken($user_id); $user['token'] = self::CreatedUserToken($user_id);
if(Db::name('User')->where(['id'=>$user_id])->update(['token'=>$user['token'], 'upd_time'=>time()])) if(Db::name('User')->where(['id'=>$user_id])->update(['token'=>$user['token'], 'upd_time'=>time()]))
{ {
MyCache(MyConfig('shopxo.cache_user_info').$user['token'], $user); MyCache(SystemService::CacheKey('shopxo.cache_user_info').$user['token'], $user);
} }
// web端用户登录纪录处理 // web端用户登录纪录处理
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册