Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
ylc.llewan.com
Project
Project
Details
Activity
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
llewan
ylc.llewan.com
Commits
2d408ccc
Commit
2d408ccc
authored
Dec 12, 2018
by
734642908@qq.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
测试自增id
parent
e83d356e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
0 deletions
+35
-0
function.php
Application/Common/Common/function.php
+6
-0
FlushController.class.php
Application/Home/Controller/FlushController.class.php
+29
-0
No files found.
Application/Common/Common/function.php
View file @
2d408ccc
...
@@ -488,4 +488,9 @@ function curlPost($url,$data='',$is_ssl = false) {
...
@@ -488,4 +488,9 @@ function curlPost($url,$data='',$is_ssl = false) {
// 关闭
// 关闭
curl_close
(
$ch
);
curl_close
(
$ch
);
return
$re
;
return
$re
;
}
function
getTime
()
{
list
(
$microsecond
,
$time
)
=
explode
(
' '
,
microtime
());
//' '中间是一个空格
return
(
float
)
sprintf
(
'%.0f'
,(
floatval
(
$microsecond
)
+
floatval
(
$time
))
*
1000
);
}
}
\ No newline at end of file
Application/Home/Controller/FlushController.class.php
View file @
2d408ccc
...
@@ -69,6 +69,34 @@ class FlushController extends BaseController
...
@@ -69,6 +69,34 @@ class FlushController extends BaseController
}
}
public
function
testId
()
{
//连接本地的 Redis 服务
$redis
=
S
(
C
(
'REDIS'
));
while
(
$redis
->
setnx
(
'test_lock'
,
getTime
()
+
100
)
==
0
)
{
if
(
getTime
()
>
$redis
->
get
(
'test_lock'
)
&&
getTime
()
>
$redis
->
getset
(
'test_lock'
,
getTime
()
+
100
)){
break
;
}
else
{
usleep
(
100000
);
}
}
$id
=
$redis
->
get
(
'test_id'
);
if
(
empty
(
$id
))
{
$id
=
100
;
}
else
{
$id
++
;
}
$redis
->
set
(
'test_id'
,
$id
);
echo
$id
;
$redis
->
del
(
'test_lock'
);
}
}
}
?>
?>
\ No newline at end of file
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