Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
starsw001
ShopXO
提交
8253a0ce
ShopXO
项目概览
starsw001
/
ShopXO
与 Fork 源项目一致
Fork自
纵之格 / ShopXO
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
ShopXO
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
8253a0ce
编写于
11月 15, 2020
作者:
D
devil
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
redis缓存配置方式优化
上级
7d2b1cc7
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
95 addition
and
225 deletion
+95
-225
application/admin/controller/Site.php
application/admin/controller/Site.php
+0
-10
application/install/controller/Index.php
application/install/controller/Index.php
+0
-8
application/service/BaseConfigHandleService.php
application/service/BaseConfigHandleService.php
+0
-204
config/.gitignore
config/.gitignore
+1
-3
config/cache.php
config/cache.php
+45
-0
config/session.php
config/session.php
+49
-0
未找到文件。
application/admin/controller/Site.php
浏览文件 @
8253a0ce
...
...
@@ -12,7 +12,6 @@ namespace app\admin\controller;
use
app\service\ConfigService
;
use
app\service\GoodsService
;
use
app\service\BaseConfigHandleService
;
/**
* 站点设置
...
...
@@ -257,15 +256,6 @@ class Site extends Common
case
'forgetpwd'
:
cache
(
config
(
'shopxo.cache_user_forgetpwd_left_key'
),
null
);
break
;
// 缓存
case
'cache'
:
$res
=
BaseConfigHandleService
::
Run
();
if
(
$res
[
'code'
]
!=
0
)
{
return
$res
;
}
break
;
}
}
...
...
application/install/controller/Index.php
浏览文件 @
8253a0ce
...
...
@@ -11,7 +11,6 @@
namespace
app\install\controller
;
use
think\Db
;
use
app\service\BaseConfigHandleService
;
/**
* 安装程序
...
...
@@ -161,13 +160,6 @@ class Index extends Common
die
(
'非法访问'
);
}
// 校验cache和session配置生成
$ret
=
BaseConfigHandleService
::
Run
();
if
(
$ret
[
'code'
]
!=
0
)
{
return
$ret
;
}
// 参数
$params
=
input
(
'post.'
);
$ret
=
$this
->
ParamsCheck
(
$params
);
...
...
application/service/BaseConfigHandleService.php
已删除
100644 → 0
浏览文件 @
7d2b1cc7
<?php
// +----------------------------------------------------------------------
// | ShopXO 国内领先企业级B2C免费开源电商系统
// +----------------------------------------------------------------------
// | Copyright (c) 2011~2019 http://shopxo.net All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: Devil
// +----------------------------------------------------------------------
namespace
app\service
;
/**
* 基础配置处理服务层
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2020-09-25
* @desc description
*/
class
BaseConfigHandleService
{
/**
* 运行入口
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2020-09-25
* @desc description
* @param [array] $params [输入参数]
*/
public
static
function
Run
(
$params
=
[])
{
// session配置
$ret
=
self
::
SessionHandle
(
$params
);
if
(
$ret
[
'code'
]
!=
0
)
{
return
$ret
;
}
// cache配置
$ret
=
self
::
CacheHandle
(
$params
);
if
(
$ret
[
'code'
]
!=
0
)
{
return
$ret
;
}
}
/**
* session配置处理
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2020-09-25
* @desc description
* @param [array] $params [输入参数]
*/
public
static
function
SessionHandle
(
$params
=
[])
{
if
(
MyC
(
'common_session_is_use_cache'
)
==
1
)
{
$config
=
[
// 使用redis
'type'
=>
'redis'
,
// 连接地址
'host'
=>
MyC
(
'common_cache_session_redis_host'
,
'127.0.0.1'
,
true
),
// 端口号
'port'
=>
MyC
(
'common_cache_session_redis_port'
,
6379
,
true
),
// 密码
'password'
=>
MyC
(
'common_cache_session_redis_password'
,
''
,
true
),
// 全局缓存有效期、默认3600秒
'expire'
=>
MyC
(
'common_cache_session_redis_expire'
,
3600
,
true
),
// 缓存前缀
'prefix'
=>
MyC
(
'common_cache_session_redis_prefix'
,
'shopxo'
,
true
),
];
}
else
{
$config
=
[
// session_id
'id'
=>
''
,
// SESSION_ID的提交变量,解决flash上传跨域
'var_session_id'
=>
''
,
// SESSION 前缀
'prefix'
=>
'shopxo'
,
// 驱动方式 支持redis memcache memcached
'type'
=>
''
,
// 过期时间(默认3600秒)
'expire'
=>
3600
,
// 是否自动开启 SESSION
'auto_start'
=>
true
,
];
}
// 配置文件
$file_dir
=
ROOT
.
'config'
.
DS
;
$file_name
=
'session.php'
;
// 保存文件
return
self
::
ConfigFileSave
(
$file_dir
,
$file_name
,
$config
,
'Session配置'
);
}
/**
* cache配置处理
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2020-09-25
* @desc description
* @param [array] $params [输入参数]
*/
public
static
function
CacheHandle
(
$params
=
[])
{
// 是否使用缓存
if
(
MyC
(
'common_data_is_use_cache'
)
==
1
)
{
$config
=
[
// 使用redis
'type'
=>
'redis'
,
// 连接地址
'host'
=>
MyC
(
'common_cache_data_redis_host'
,
'127.0.0.1'
,
true
),
// 端口号
'port'
=>
MyC
(
'common_cache_data_redis_port'
,
6379
,
true
),
// 密码
'password'
=>
MyC
(
'common_cache_data_redis_password'
,
''
,
true
),
// 全局缓存有效期(0为永久有效)
'expire'
=>
MyC
(
'common_cache_data_redis_expire'
,
0
,
true
),
// 缓存前缀
'prefix'
=>
MyC
(
'common_cache_data_redis_prefix'
,
'shopxo'
,
true
),
];
}
else
{
$config
=
[
// 驱动方式
'type'
=>
'File'
,
// 缓存保存目录
'path'
=>
''
,
// 缓存前缀
'prefix'
=>
'shopxo'
,
// 缓存有效期 0表示永久缓存
'expire'
=>
0
,
];
}
// 配置文件
$file_dir
=
ROOT
.
'config'
.
DS
;
$file_name
=
'cache.php'
;
// 保存文件
return
self
::
ConfigFileSave
(
$file_dir
,
$file_name
,
$config
,
'缓存配置'
);
}
/**
* 配置文件保存
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2020-09-25
* @desc description
* @param [string] $file_dir [文件路径]
* @param [string] $file_name [文件名称]
* @param [array] $config [配置信息]
* @param [string] $name [描述名称]
*/
private
static
function
ConfigFileSave
(
$file_dir
,
$file_name
,
$config
,
$name
)
{
// 是否有写权限
$config_file
=
$file_dir
.
$file_name
;
if
(
file_exists
(
$config_file
))
{
if
(
!
is_writable
(
$config_file
))
{
return
DataReturn
(
$name
.
'文件没有操作权限'
.
'['
.
$config_file
.
']'
,
-
10
);
}
}
else
{
if
(
!
is_dir
(
$file_dir
))
{
return
DataReturn
(
$name
.
'路径不存在'
.
'['
.
$file_dir
.
']'
,
-
11
);
}
if
(
!
is_writable
(
$file_dir
))
{
return
DataReturn
(
$name
.
'路径没有操作权限'
.
'['
.
$file_dir
.
']'
,
-
12
);
}
}
// 生成配置文件
$ret
=
@
file_put_contents
(
$config_file
,
"<?php
// +----------------------------------------------------------------------
// | ShopXO 国内领先企业级B2C免费开源电商系统
// +----------------------------------------------------------------------
// | Copyright (c) 2011~2019 http://shopxo.net All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: Devil
// +----------------------------------------------------------------------
//
{
$name
}
\n
return "
.
var_export
(
$config
,
true
)
.
";
\n
?>"
);
if
(
$ret
===
false
)
{
return
DataReturn
(
$name
.
'处理失败['
.
$config_file
.
']'
,
-
100
);
}
return
DataReturn
(
'处理成功'
,
0
);
}
}
?>
\ No newline at end of file
config/.gitignore
浏览文件 @
8253a0ce
database.php
cache.php
session.php
\ No newline at end of file
database.php
\ No newline at end of file
config/cache.php
0 → 100755
浏览文件 @
8253a0ce
<?php
// +----------------------------------------------------------------------
// | ShopXO 国内领先企业级B2C免费开源电商系统
// +----------------------------------------------------------------------
// | Copyright (c) 2011~2019 http://shopxo.net All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: Devil
// +----------------------------------------------------------------------
// 是否开启redis
$common_data_is_use_cache
=
MyFileConfig
(
'common_data_is_use_cache'
,
''
,
0
,
true
);
if
(
$common_data_is_use_cache
==
1
)
{
// redis配置
$config
=
[
// 使用redis
'type'
=>
'redis'
,
// 连接地址
'host'
=>
MyFileConfig
(
'common_cache_data_redis_host'
,
''
,
'127.0.0.1'
,
true
),
// 端口号
'port'
=>
MyFileConfig
(
'common_cache_data_redis_port'
,
''
,
6379
,
true
),
// 密码
'password'
=>
MyFileConfig
(
'common_cache_data_redis_password'
,
''
,
''
,
true
),
// 全局缓存有效期(0为永久有效)
'expire'
=>
MyFileConfig
(
'common_cache_data_redis_expire'
,
''
,
0
,
true
),
// 缓存前缀
'prefix'
=>
MyFileConfig
(
'common_cache_data_redis_prefix'
,
''
,
'shopxo'
,
true
),
];
}
else
{
// 默认配置
$config
=
[
// 驱动方式
'type'
=>
'File'
,
// 缓存保存目录
'path'
=>
''
,
// 缓存前缀
'prefix'
=>
'shopxo'
,
// 缓存有效期 0表示永久缓存
'expire'
=>
0
,
];
}
return
$config
;
?>
\ No newline at end of file
config/session.php
0 → 100755
浏览文件 @
8253a0ce
<?php
// +----------------------------------------------------------------------
// | ShopXO 国内领先企业级B2C免费开源电商系统
// +----------------------------------------------------------------------
// | Copyright (c) 2011~2019 http://shopxo.net All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: Devil
// +----------------------------------------------------------------------
// 是否开启redis
$common_session_is_use_cache
=
MyFileConfig
(
'common_session_is_use_cache'
,
''
,
0
,
true
);
if
(
$common_session_is_use_cache
==
1
)
{
// redis配置
$config
=
[
// 使用redis
'type'
=>
'redis'
,
// 连接地址
'host'
=>
MyFileConfig
(
'common_cache_session_redis_host'
,
''
,
'127.0.0.1'
,
true
),
// 端口号
'port'
=>
MyFileConfig
(
'common_cache_session_redis_port'
,
''
,
6379
,
true
),
// 密码
'password'
=>
MyFileConfig
(
'common_cache_session_redis_password'
,
''
,
''
,
true
),
// 全局缓存有效期、默认3600秒
'expire'
=>
MyFileConfig
(
'common_cache_session_redis_expire'
,
''
,
3600
,
true
),
// 缓存前缀
'prefix'
=>
MyFileConfig
(
'common_cache_session_redis_prefix'
,
''
,
'shopxo'
,
true
),
];
}
else
{
// 默认配置
$config
=
[
// session_id
'id'
=>
''
,
// SESSION_ID的提交变量,解决flash上传跨域
'var_session_id'
=>
''
,
// SESSION 前缀
'prefix'
=>
'shopxo'
,
// 驱动方式 支持redis memcache memcached
'type'
=>
''
,
// 过期时间(默认3600秒)
'expire'
=>
3600
,
// 是否自动开启 SESSION
'auto_start'
=>
true
,
];
}
return
$config
;
?>
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录