Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
xuzhenhao
/
rlw-dev
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit a457569b
authored
Dec 28, 2017
by
xuzhenhao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加了redis工具库中的方法
1 parent
ee03c575
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
6 deletions
sdkredis/ice_gametopREDIS.go
sdkredis/redisCommon.go
sdkredis/ice_gametopREDIS.go
View file @
a457569
...
...
@@ -463,7 +463,7 @@ func IceGameTopRedisGetSingleUserRangeRankInfo(uid string, gtid string, gid stri
}
else
if
sorceorder
==
"0"
{
if
nextrankIndex
!=
0
{
strList1
,
err
=
RedisZRangeByScore
(
redisConn
,
"sortset:gtid:"
+
gtid
+
":gid:"
+
gid
+
":toptype:"
+
toptype
,
score
,
"+inf"
,
"true"
,
0
,
prerankIndex
)
strList1
,
err
=
RedisZRangeByScore
(
redisConn
,
"sortset:gtid:"
+
gtid
+
":gid:"
+
gid
+
":toptype:"
+
toptype
,
score
String
,
"+inf"
,
"true"
,
0
,
prerankIndex
)
//将结果倒序
var
tempList
[]
string
for
i
:=
len
(
strList1
);
i
<
0
;
i
-=
2
{
...
...
@@ -473,7 +473,7 @@ func IceGameTopRedisGetSingleUserRangeRankInfo(uid string, gtid string, gid stri
strList1
=
tempList
}
if
prerankIndex
!=
0
{
strList2
,
err
=
RedisZRevRangeByScore
(
redisConn
,
"sortset:gtid:"
+
gtid
+
":gid:"
+
gid
+
":toptype:"
+
toptype
,
score
,
"-inf"
,
"true"
,
0
,
nextrankIndex
)
strList2
,
err
=
RedisZRevRangeByScore
(
redisConn
,
"sortset:gtid:"
+
gtid
+
":gid:"
+
gid
+
":toptype:"
+
toptype
,
score
String
,
"-inf"
,
"true"
,
0
,
nextrankIndex
)
}
if
len
(
strList1
)
==
0
{
...
...
@@ -603,8 +603,7 @@ func GetSingleUserRank(key string, member string) (rankIndex interface{}, err er
defer
RedisClose
(
redisConn
)
rank
,
err
:=
RedisZRank
(
redisConn
,
key
,
member
)
if
err
!=
nil
{
resIndex
=
"105202"
return
resIndex
,
err
return
"105202"
,
err
}
if
rank
==
nil
{
err
=
errors
.
New
(
"用户未提交分数"
)
...
...
@@ -613,4 +612,5 @@ func GetSingleUserRank(key string, member string) (rankIndex interface{}, err er
log
.
Println
(
"key:"
,
key
)
log
.
Println
(
"rank:"
,
rank
)
rankIndex
=
int
(
rank
.
(
int64
))
return
rankIndex
,
nil
}
sdkredis/redisCommon.go
View file @
a457569
...
...
@@ -227,7 +227,7 @@ func RedisZRank(conn redis.Conn, key string, member string) (reply interface{},
/*
* zrangebyscore
*/
func
RedisZRangeByScore
(
conn
redis
.
Conn
,
key
string
,
startScore
string
,
endScore
string
,
limit
string
,
limitStart
int
,
limitEnd
int
)
(
reply
interface
{}
,
err
error
)
{
func
RedisZRangeByScore
(
conn
redis
.
Conn
,
key
string
,
startScore
string
,
endScore
string
,
limit
string
,
limitStart
int
,
limitEnd
int
)
(
reply
[]
string
,
err
error
)
{
if
limit
==
"true"
{
return
RedisCommand
(
conn
,
"zrangebyscore"
,
key
,
startScore
,
endScore
,
"withscore"
,
"limit"
,
limitStart
,
limitEnd
)
}
...
...
@@ -237,7 +237,7 @@ func RedisZRangeByScore(conn redis.Conn, key string, startScore string, endScore
/*
* zrevrangebyscore
*/
func
RedisZRevRangeByScore
(
conn
redis
.
Conn
,
key
string
,
startScore
string
,
endScore
string
,
limit
string
,
limitStart
int
,
limitEnd
int
)
(
reply
interface
{}
,
err
error
)
{
func
RedisZRevRangeByScore
(
conn
redis
.
Conn
,
key
string
,
startScore
string
,
endScore
string
,
limit
string
,
limitStart
int
,
limitEnd
int
)
(
reply
[]
string
,
err
error
)
{
if
limit
==
"true"
{
return
RedisCommand
(
conn
,
"zrevrangebyscore"
,
key
,
startScore
,
endScore
,
"withscore"
,
"limit"
,
limitStart
,
limitEnd
)
}
...
...
Write
Preview
Markdown
is supported
Attach a file
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 post a comment