Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
goods
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
bp
goods
Commits
48d20e08
Commit
48d20e08
authored
Nov 05, 2021
by
顾文旭
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix redis
parent
b25a9123
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
7 deletions
+7
-7
CacheUtil.php
vendor/api/php_utils/src/Cache/CacheUtil.php
+7
-7
No files found.
vendor/api/php_utils/src/Cache/CacheUtil.php
View file @
48d20e08
...
@@ -24,7 +24,7 @@ class CacheUtil
...
@@ -24,7 +24,7 @@ class CacheUtil
const
EXPIRE_AFTER_THREE_DAYS
=
259200
;
const
EXPIRE_AFTER_THREE_DAYS
=
259200
;
const
EXPIRE_AFTER_FIFTEEN_DAYS
=
1296000
;
const
EXPIRE_AFTER_FIFTEEN_DAYS
=
1296000
;
const
EXPIRE_AFTER_ONE_MONTH
=
2592000
;
const
EXPIRE_AFTER_ONE_MONTH
=
2592000
;
private
static
$instances
=
[];
private
static
$instances
=
[];
private
$handler
=
null
;
private
$handler
=
null
;
private
$expire
=
86400
;
//@todo 讨论一下,如果不设置有效时间,默认1天,不允许设置长期有效
private
$expire
=
86400
;
//@todo 讨论一下,如果不设置有效时间,默认1天,不允许设置长期有效
...
@@ -40,7 +40,7 @@ class CacheUtil
...
@@ -40,7 +40,7 @@ class CacheUtil
* @param boolean $master
* @param boolean $master
* @return mixed
* @return mixed
*/
*/
public
static
function
getInstance
(
$serverName
=
''
,
array
$options
=
[])
public
static
function
getInstance
(
$serverName
=
''
,
array
$options
=
[])
{
{
if
(
empty
(
$serverName
))
{
if
(
empty
(
$serverName
))
{
return
null
;
return
null
;
...
@@ -53,7 +53,7 @@ class CacheUtil
...
@@ -53,7 +53,7 @@ class CacheUtil
if
(
isset
(
self
::
$instances
[
$instancesKey
]))
{
if
(
isset
(
self
::
$instances
[
$instancesKey
]))
{
return
self
::
$instances
[
$instancesKey
];
return
self
::
$instances
[
$instancesKey
];
}
}
return
self
::
$instances
[
$instancesKey
]
=
new
Self
(
$serverName
,
$options
);
return
self
::
$instances
[
$instancesKey
]
=
new
Self
(
$serverName
,
$options
);
}
}
...
@@ -87,7 +87,7 @@ class CacheUtil
...
@@ -87,7 +87,7 @@ class CacheUtil
if
(
is_null
(
$value
)
||
false
===
$value
)
{
if
(
is_null
(
$value
)
||
false
===
$value
)
{
return
$default
;
return
$default
;
}
}
return
$value
;
return
json_decode
(
$value
)
;
}
}
/**
/**
...
@@ -123,9 +123,9 @@ class CacheUtil
...
@@ -123,9 +123,9 @@ class CacheUtil
$key
=
$this
->
getCacheKey
(
$prefix
,
$key
);
$key
=
$this
->
getCacheKey
(
$prefix
,
$key
);
//对数组/对象数据进行缓存处理,保证数据完整性
//对数组/对象数据进行缓存处理,保证数据完整性
if
(
is_int
(
$expire
)
&&
$expire
)
{
if
(
is_int
(
$expire
)
&&
$expire
)
{
$result
=
$this
->
handler
->
setex
(
$key
,
$expire
,
$value
);
$result
=
$this
->
handler
->
setex
(
$key
,
$expire
,
json_encode
(
$value
)
);
}
else
{
}
else
{
$result
=
$this
->
handler
->
set
(
$key
,
$value
);
$result
=
$this
->
handler
->
set
(
$key
,
json_encode
(
$value
)
);
}
}
return
$result
;
return
$result
;
}
}
...
@@ -282,7 +282,7 @@ class CacheUtil
...
@@ -282,7 +282,7 @@ class CacheUtil
$keyArr
[]
=
$prefix
.
$val
;
$keyArr
[]
=
$prefix
.
$val
;
}
}
return
$keyArr
;
return
$keyArr
;
}
}
return
$prefix
.
$key
;
return
$prefix
.
$key
;
}
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment